Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Number of links from a particular link category
Is there a way to show in the front end, the number of links from a particular link category?
Something like the functionality of mdn_count but for link categories.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Number of links from a particular link category
It’s a simple query:
SELECT COUNT(*) FROM txp_link WHERE category = 'the_category'
which you can run via:
safe_count('txp_link', "category = 'the_category'");
(better because then safe_prefix()
is built in)
or via smd_query (likewise).
I wouldn’t necessarily want to take this approach for a long category list, however — too many queries.
Code is topiary
Offline
Re: Number of links from a particular link category
Hi Jeff thanks for the quick reply but it doesn’t seem to work. It is 100% my fault though… I’m sure
This is what I have inserted in the page
<txp:php>safe_count('txp_link', "category = 'contributors'");</txp:php>
I wouldn’t necessarily want to take this approach for a long category list, however – too many queries.
What would a long list be? I currently have just under 400 links. Would that be too many queries?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Number of links from a particular link category
Try:
<txp:php>echo safe_count('txp_link', "category = 'contributors'");</txp:php>
colak wrote:
What would a long list be? I currently have just under 400 links. Would that be too many queries?
It’s the number of categories you want to display on the page that matters.
Code is topiary
Offline
Re: Number of links from a particular link category
jsoo wrote:
Try:
<txp:php>echo safe_count('txp_link', "category = 'contributors'");</txp:php>
oops. missed the echo
. Thanks… this works:)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline