Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Plugin support
  3. » mdn_count

#61 2009-03-06 17:47:33

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: mdn_count

Hi

Try ….

<txp:variable name=“article_count” value=“0”/>
<txp:article_custom form=“article_count” limit=“1000000” />

with

<txp:adi_calc name=“article_count” add=“1”/> as the one line in form “article_count”

You can then use all the possible combinations of article_custom

Geoff


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#62 2010-10-30 11:43:23

b2872387
New Member
Registered: 2010-10-30
Posts: 1

Re: mdn_count

This is such a simple but useful plugin. There are a couple of other plugins that will let you so queries on the DB, but there’s not point having such a complex plugin when all you want to do is a quick article count.

Its strange this isn’t core functionality yet. There’s comment count and search result count, but no article count.

Offline

#63 2010-10-30 11:43:39

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: mdn_count

mdn_count

Version 2.2 – updated 2013-09-09 (source).

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 " customfield=" my,custom,fields " customvalue=" custom,field,values " debug=" true " />

  • Using the tag without any attributes will return a count of all articles that are both live and current (not expired or future).
  • Specifying a section or a category will show a count of articles in that section/category.
  • Specifying both a section and a category will show articles in the intersection of the two criteria.
  • The status attribute defaults to 4 (live), and also accepts 1 (draft), 2 (hidden), 3 (pending), and 5 (sticky) – please use the numbers only.
  • The time attribute defaults to now, and also accepts past and future – new in v2.1.
  • The customfield and customvalue parameters need to be used together, and will further restrict the count to articles with custom fields that contain only a certain value.
  • Setting debug to true will show the query being run in the form of a HTML comment.

All attributes are both optional and accept multiple values (in the form of a comma separated list, with the exception of debug).

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.

Last edited by radneck (2015-11-04 21:21:19)

Offline

#64 2010-10-30 13:54:23

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: mdn_count

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

#65 2010-10-30 16:15:56

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: mdn_count

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)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#66 2010-10-31 01:26:56

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: mdn_count

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.

Offline

#67 2010-10-31 02:16:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: mdn_count

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.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#68 2010-10-31 02:18:57

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: mdn_count

colak wrote:

Maybe the inactivity lies in its not having any problems:)

You could well be right there :)

Offline

#69 2010-11-05 03:31:45

Bill Grimm
New Member
From: Colorado
Registered: 2010-01-25
Posts: 8

Re: mdn_count

Is there a way to only count the articles in a given category that have not expired?

Offline

#70 2010-11-05 05:57:37

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: mdn_count

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.

Last edited by radneck (2015-11-04 07:42:50)

Offline

#71 2010-11-05 18:21:56

Bill Grimm
New Member
From: Colorado
Registered: 2010-01-25
Posts: 8

Re: mdn_count

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

#72 2010-11-06 01:53:04

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: mdn_count

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.

Last edited by radneck (2015-11-04 07:42:39)

Offline

  1. Index
  2. » Plugin support
  3. » mdn_count

Board footer

Powered by FluxBB