Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

#1 2004-11-23 20:25:53

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

mdn_count

IMPORTANT NOTICE
As of Txp 4.3.0RC1 Remillard’s original plugin no longer works.
It is now adopted and adapted by cain-mi, for the rewritten version and instructions see post #61.

Original posting by Remillard

This plugin is … well pretty basic. It will count the number of live articles in a section, or category.

Usage:

<txp:mdn_count [section="sectionname"] [category="text"] />

NOTE: The items in square brackets are optional and the brackets should not be used in the construction of the tag.

Parameters

  • section – This item is OPTIONAL. The plugin will return the number of articles in the given section name.
  • category – This item is OPTIONAL. The plugin will return the number of articles with the given category name, in either category1 OR category2.

Notes:

  • There is some basic checking. The two parameters are optional, but it doesn’t make sense if BOTH are gone. I think that’s the only one it catches.
  • Section takes precedence over category if both are specified.

Download the plugin (Newer version available, see above.)
Version: 1.4

Changes since 1.3: There was a logic error that made it possible for the plugin to count the occasional draft copy if the category match was in category2.
Changes since 1.2: Added the ability to count the intersection of section and category, and removed the error message if there were no qualified count parameters specified.
Changes since 1.1: Fixed the ability mentioned below because I was stupid and did the change too fast. It ought to actually work now.
Changes since 1.0: Added the ability to take the section name or category name from the current section or category by calling out section=”#”, or category=”#”.

Regards,
Remillard

Last edited by uli (2012-11-30 15:15:40)

Offline

#2 2004-11-23 22:48:01

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: mdn_count

Will this count needles??


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2004-11-23 23:11:26

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

Re: mdn_count

Er, no. Just articles in sections and categories. It’s very limited in that respect. I had an entire list of functional requirements for this one, and finally after much work I had to omit the “count the number of needles in Textpattern”.

Terribly sorry about that.

Offline

#4 2004-11-23 23:34:53

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: mdn_count

Ha ha. And you seemed to working so hard on that PHP.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#5 2004-11-23 23:37:02

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

Re: mdn_count

:-) Well actually the hard plugin was the mdn_if_custom one… getting the searches to work right was sort of tricky. <code>stripos()</code> is only in PHP 5, so I had to start working around case issues… and then getting the <code><else /></code> was interesting.

But it was still pretty much a day long PHP project… not a lengthy one.

Offline

#6 2004-11-23 23:53:14

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: mdn_count

Yes that does look a little complex though I don’t have a need for such a thing at the moment.


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#7 2004-11-24 18:18:34

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: mdn_count

Thank you for this plugin, I’ve been wanting this for a long time.
Is there also a way to make it count the articles in the current category? I tried something like <code>category=<txp:c /></code> but that doesn’t work.

Last edited by doggiez (2004-11-24 18:19:25)

Offline

#8 2004-11-24 20:16:06

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

Re: mdn_count

Mmm… interesting idea to embed tags into parameters. Unfortunately no, it doesn’t do this, although it might not be too hard. If you wanted to try, go into the code on the plugin and put in something like this:

<code> $category = parse($category); </code>

Put it somewhere after the beginning and before it’s used and see what happens.

Offline

#9 2004-11-24 21:09:23

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: mdn_count

Whoops! Got it working! With hardly any php knowledge…

I changed the last part into:

<code>
$category = parse($GLOBALS[“c”]);
$q = “SELECT COUNT count FROM “.PFX.“textpattern WHERE
category1=’$category’ OR category2=’$category’ AND status=‘4’”;
$rs = getRows($q);
return ($rs0[‘count’]);
</code>

(parse($category) gave the the total amount of articles in all categories)

Thank you!

EDIT:
Haha, that was not that smart, because on another page I used the original plugin, which now won’t work anymore…
Is there a way to copy my modification and save it as another plugin?

Last edited by doggiez (2004-11-24 21:12:50)

Offline

#10 2004-11-24 21:20:02

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

Re: mdn_count

Glad it worked. I think you could just put the parse category thing in there, and then use a tag in the parameter… er, well that might screw up the regular expression for the callback… this is maybe better.

As for a new version… unfortunately, not really. You’d have to put it into the plugin template, generate the md5 code and reupload it.

Offline

#11 2004-11-24 21:33:13

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

Re: mdn_count

On second thought, maybe the best thing to do, is for me to just add an option for current section and current category… then you can use it in both places…

be right back…

I’m back. Currently the file at the link is version 1.1, and contains the following modification.

If section or category are marked as “#”, then the current section or category will be used for counting.

See if that helps.

Last edited by Remillard (2004-11-24 21:40:50)

Offline

#12 2004-11-24 23:36:14

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: mdn_count

:) go Remillard go!


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

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

Board footer

Powered by FluxBB