You are not logged in.
Version 2.1.1 – updated 2010-11-05.
I am not the original author, but I use this plugin and when I updated to the 4.3.0 RC it no longer worked, so I gave it a quick do-over.
<txp:mdn_count section=" sectionname " category=" categoryname " status=" 1,2,3,4,5 " time=" now,past,future " />
section or a category will show a count of articles in that section/category.section and a category will show articles in the intersection of the two criteria.status attribute defaults to 4 (live), and also accepts 1 (draft), 2 (hidden), 3 (pending), and 5 (sticky) – please use the numbers only.time attribute defaults to now, and also accepts past and future – new in v2.1.All attributes are both optional and accept multiple values (in the form of a comma separated list).
Plugin originally by Mark Norton, v2.0+ rewritten by me :)
Tested on 4.2.0 and 4.3.0, but should work on all versions of Textpattern.
Please let me know if you find any bugs.
Cheers,
Mitch.
Last edited by cain-mi (2013-03-20 04:08:20)
Away for a while, all plugins will be updated in 2013
Offline
Thanks. I’m glad there’s still a point to it, but I’m just not doing any web work anymore at the moment. The txp-dev listserv has been pretty active and seems receptive of late to modifications. If it’s believed this should be core functionality, you might submit the working version to them, see what arises.
Offline
cain-mi wrote:
Version 2.0 – completely rewritten 2010-10-30.
Remillard wrote:
Thanks. I’m glad there’s still a point to it, but I’m just not doing any web work anymore at the moment.
Hi Mitch, since Mark is not working on the plugin anymore, maybe a new thread for your modified plugin should be opened?
Last edited by colak (2010-10-30 16:16:32)
neme.org | neme-imca.org | hblack.net | LABS
Offline
colak wrote:
Hi Mitch, since Mark is not working on the plugin anymore, maybe a new thread for your modified plugin should be opened?
I thought about that, but seeing as this plugin doesn’t have a huge following (only a couple of posts in this thread in the last two years), there was no point fragmenting it. Els added a note on the OP linking to my updated one, and I added a comment on the TXP Resources listing, so hopefully everyone will be able to work out what’s going on.
Away for a while, all plugins will be updated in 2013
Offline
cain-mi wrote:
I thought about that, but seeing as this plugin doesn’t have a huge following (only a couple of posts in this thread in the last two years), there was no point fragmenting it.
I’m using the plugin:) Maybe the inactivity lies in its not having any problems:) i’ll be downloading yours very soon. Thanks for adopting it.
neme.org | neme-imca.org | hblack.net | LABS
Offline
Is there a way to only count the articles in a given category that have not expired?
Offline
Hi Bill,
Excellent point – I’ve updated the plugin so that by default articles are only counted if they are both live and current (i.e. not expired and not in the future).
Please give it a crack and let me know how it goes.
For anyone depending on counting expired or future articles as well, there is a new time tag – check the main post for details.
Cheers,
Mitch.
Last edited by cain-mi (2010-11-05 11:25:25)
Away for a while, all plugins will be updated in 2013
Offline
That works great! Thank you very much! Though you may want to add the option ‘all’ to the time attribute in case people want a total count of all articles (like it used to supply)? I don’t have a use for that myself, though.
I was actually needing it to tell me if I have more than a certain number of articles in a section so I could then provide a link to the rest of them (with excerpts on the opening list). I could not find a way to use txp:variable to do this comparison, so I modified the return value from mdn_count to basically give me a yes or no type of value instead of the actual count (send back a 5 if there are more than 5 articles — the number of articles I give a preview for — or a 0 if there are 5 or fewer). I could then use txp:variable to determine the answer to the yes/no question of whether I needed a link or not.
Have I gone roundabout on an issue that has a simpler solution?
Last edited by Bill Grimm (2010-11-05 18:26:32)
Offline
Well it depends if you are going to use mdn_count in any other part of your templates/forms. If this is your only use of this plugin, then modifying it as you have it probably the best method. If you want to use this plugin again (using the way it was originally coded – to return a number), then you’re better off wrapping it in smd_if – use something like this:
<txp:smd_if field='<txp:mdn_count section="foobar" />' operator="gt" value="5">
do stuff here for more than five articles
<txp:else />
do stuff here for 5 or less articles
</txp:smd_if>
In regard to adding all as a value for the time attribute, this isn’t necessary because it accepts multiple values – you can use now,past,future and every single article will be counted.
Cheers,
Mitch.
Away for a while, all plugins will be updated in 2013
Offline