Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#16 2004-11-25 14:07:14
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: mdn_count
> Remillard wrote:
> 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.
With YellowDuck’s changes it works perfectly, thank you again!
Offline
#17 2004-11-25 15:23:25
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: mdn_count
whups… I’ll go fix that… Duck is right, it needs to be a double = for comparison.
As far as iteratively, I’m not sure what you mean precisely. You can call it multiple times, sure. It doesn’t iterate by itself though over categories. you would have to have a tag instance for each category you wanted counted.
Okay, well off to fix that comparison. 1.2 will be up in short order.
Done. Hope it’s okay now.
Last edited by Remillard (2004-11-25 15:26:56)
Offline
#18 2004-11-25 15:28:56
- humanoid
- Member

- Registered: 2004-06-24
- Posts: 17
Re: mdn_count
—-
As far as iteratively, I’m not sure what you mean precisely. You can call it multiple times, sure. It doesn’t iterate by itself though over categories. you would have to have a tag instance for each category you wanted counted.
—-
yeah I know I can just call the plugin repeatedly (once for every section). Hmm, maybe I should just do that, it is too complex for me to dive into the php and change it so it gives bac a whole list of all cat’s + numbers.
Thanks for the answer anyway.
Offline
Re: mdn_count
my impression of what humanoid suggested in terms of ‘iteratively’ as a list of categories, is that it’s the same thing as what i’m suggesting here
textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation
Offline
#20 2004-11-25 16:14:23
- humanoid
- Member

- Registered: 2004-06-24
- Posts: 17
Re: mdn_count
You are absolutely right. It would be great to combine the two you mention. I will have a go at it myself maybe, but chance I will not succeed is pretty high (no php knowledge etc).
Offline
#21 2004-11-25 16:24:20
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: mdn_count
Well almost the same.
A few ideas:
It might be interesting to write a category iterator plugin. It doesn’t necessarily do anything by itself but it would process what’s enclosed for every category. The same for section.
However, the main difference is that you asked for categories IN a section. That’s not hard, just different. The count plugin currently doesn’t care about cross-associations between category and section. It just counts.
humanoid: That’s the best way to learn. I didn’t know a stitch of PHP or MySQL until working on these things (as is readily apparant from missing the equal sign comparison earlier…sheesh, I’m still kicking myself for that one).
It’s a holiday weekend, so we’ll see what happens, but maybe I can work on an iterator plugin for fun with various options with respect to section and category.
Offline
Re: mdn_count
honestly, it woud be useful to know the count of articles in a whole category, as well as a category within a particular section..
it seems like an ambitious project to me, though… maybe you’d like to rest your head sometime :)
anyway, we’ve lived without it so far, so while it would be nice to see either Remillard or humanoid or some other brave soul take it on, i think we can be patient for however long it takes.
textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation
Offline
#23 2004-11-25 16:43:33
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: mdn_count
The more I think about it, I think it would be pretty easy to do this with the current plugin. I’ll take a peek.
Offline
#24 2004-11-25 16:52:30
- humanoid
- Member

- Registered: 2004-06-24
- Posts: 17
Re: mdn_count
Go Remillard Go :-)
In the meantime I was heavily looking at
==
if ($section) $section_q = “AND Section=’$section’”;
print “<!— section_q=$section_q —>\n”;
$rs = getRows(“SELECT DISTINCT c.name FROM “.PFX.“txp_category c, “.PFX.“textpattern t WHERE (t.Category1=c.name OR t.Category2=c.name) AND t.Status=4 $section_q ORDER BY c.name ASC”);
==
But I couldn;t understand it at all :-(
Offline
#25 2004-11-25 17:00:39
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: mdn_count
I’ve got a quickly thrown together hack. It’s not tested and I don’t have a particularly good way to test it either (as I don’t use categories particularly.)
If someone wouldn’t mind trying this out, and letting me know if it does the intersection thing right, I’d appreciate it.
Hope it works :).
EDIT: As far as I could tell, the SQL you had up there was getting close to what I did. I tend not to use the table and field labels unless it’s really onerous to do so, and I used count() instead of distinct, because why do the count myself if the database can do it faster and more optimized than I can? :). But basically all it needed was a way to tell if both were specified, and then modify the SQL statement accordingly.
Last edited by Remillard (2004-11-25 17:05:04)
Offline
#26 2004-11-25 18:35:32
- humanoid
- Member

- Registered: 2004-06-24
- Posts: 17
Re: mdn_count
Ok – Let’s see
Installing….
Is it correct you didn’t change the Plugin name etc? I see this in my plugin list when installing:
mdn_count Mark Norton 1.2 Provides a count of the number of live articles by section or category, or both.
Hmm, I think I did something wrong, I used it like this on the frontpage:
<txp:mdn_count category="#" />
And then I get:
mdn_count: You did not specify section or category.
If I do:
<txp:mdn_count category="books" />
Then I get the correct number.
I was thinking actually you would let it output a list of categories? So the changes you are focussing on is that it only count categories within a certain section right? Tricky to test for me also, because I restrict certain categories to certain sections. I could play around with it though and will do so after my sports-training I have to attend now.
I will let you know my results.
Offline
Re: mdn_count
‘checked it out. it works :) beautifully.
textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation
Offline
#28 2004-11-25 19:40:14
- Remillard
- Plugin Author

- From: Lenexa, KS
- Registered: 2004-05-16
- Posts: 169
Re: mdn_count
Yes, the beta has the same name. Just the rev updates and the description a little.
Well… you need to be careful on the front page. If there is NO category context and you are saying “take it from the current category” (i.e. the # selection), then yes, it will fail. You would have to call the front page with http://mysite.com/?c=Somecategory and then the # would work because there is an established category context.
I did create some test cases on my test page and it looks like it’s picking things up. I’m glad alicson got good results too. Let me know humanoid if you can get it working for yourself.
Last edited by Remillard (2004-11-25 23:19:28)
Offline
Re: mdn_count
i didn’t try it on the front page… just on the archive page..
textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation
Offline
#30 2004-11-29 12:45:34
- humanoid
- Member

- Registered: 2004-06-24
- Posts: 17
Re: mdn_count
Hi, yeah it works OK if I call it with c=something. Maybe make it possible to suppres the error message? Or “enable verbose”. Then you could use it much more freely.
Thanks and regrads, Ed
Offline