Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#22 2004-11-25 16:31:01

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

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.

mdn_count_beta.txt

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

#27 2004-11-25 18:38:36

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

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

#29 2004-11-25 19:44:39

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

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

Board footer

Powered by FluxBB