Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2004-08-31 15:40:11
- omar
- New Member
- Registered: 2004-02-24
- Posts: 4
Request: Number of Articles in Category/Section
I would like to humbly request a plug-in that returns the number or articles in a specific category or section.
Thanks
Offline
#2 2004-08-31 15:54:36
- omar
- New Member
- Registered: 2004-02-24
- Posts: 4
Re: Request: Number of Articles in Category/Section
Ignore this request, you can accomplish this using a bit of PHP…
==
$count = td(small(safe_count(“textpattern”,
“((Category1=‘CategoryNAME’) or (Category2=‘CategoryNAME’))”)));
echo $count;
==
Replace categoryNAME with the relevant bit…
Offline
#3 2004-09-01 07:28:21
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Request: Number of Articles in Category/Section
Being new to php, can anyone please tell me how to use this code in txp please.
Thanks
Lee
Offline
#4 2004-09-01 22:19:31
- omar
- New Member
- Registered: 2004-02-24
- Posts: 4
Re: Request: Number of Articles in Category/Section
==
<?php
$category =‘NameOfCategoryYouWant”;
$catcount = (safe_count(“textpattern”, “((Category1=’$category’))”));
echo $catCount;
?>
==
place the above where you want it to appear. I’ll write a plug-in in the next few days and post it in the relavent section.
Offline
#5 2004-09-01 22:37:35
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Request: Number of Articles in Category/Section
Thanks omar. I’ll look out for the plugin.
Offline
Re: Request: Number of Articles in Category/Section
How about the number of articles in a section? I tried <code>safe_count(“textpattern”, “(section=’$section’)”);</code>
but it did not seem to work.
Offline
Re: Request: Number of Articles in Category/Section
omar,
Don’t forget to search both the Category1 and Category2 field.
michaelkpate,
Section=’$section’ should work (MySQL is case sensitive on fieldnames).
Plugins:
ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1
“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu
Offline
Re: Request: Number of Articles in Category/Section
what happened to the plugin? hehe.. :) I’ve just discovered this thread and has omar done with the plugin yet?
btw, was just wondering… MT has this simple article count (for each category) implemented (you may want to just browse through some MT sites and see that they do have an article count!) and why does TXP not have this feature yet?
Or maybe there is, but I don’t know of it, hehe.
Last edited by johnsee (2004-09-13 05:23:38)
Offline
#9 2004-09-18 21:44:59
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Request: Number of Articles in Category/Section
> omar wrote:
> ==
<?php
$category =‘NameOfCategoryYouWant”;
$catcount = (safe_count(“textpattern”, “((Category1=’$category’))”));
echo $catCount;
?>
==
> place the above where you want it to appear. I’ll write a plug-in in the next few days and post it in the relavent section.
While waiting for the plugin, what would I have to add to this code to make it count in both Category1 and Category2?
Offline