This extension adds a {count_alias} and {total_results_alias} variable to the weblog tag.
You might wonder why 😉
Sometimes I wrap a weblog tag with a query tag, for example to fetch a category_id based on a url_segment. The problem with this trick is that the {count} and {total_results} variables return the values of the query tag, instead of the weblog tag inside.
In the following example {count} will always be 1:
{exp:query sql="SELECT cat_id FROM exp_categories WHERE group_id="1" AND cat_url_title = '{segment_2}' LIMIT 1"}
{exp:weblog:entries weblog="default_site" category="{cat_id}" dynamic="off"}
{count} - {count_alias}
{/exp:weblog:entries}
{/exp:query}
Of course this problem can be workd around using some PHP but then you might run into “PHP on input/output” problems, I did!
Using this extension and the {count_alias} and {total_results_alias} variables solves the problem.
Cheers!
(the same problem is true for the {switch="one|two"} variable but that one is unfortunately not accessable through an extension hook, but please correct me if I’m wrong)
Thanks! Looks like a great extension.
Would this work with a weblog tag wrapped in a categories tag? The {count} tag is the same for both, and the {count} tag in the weblog tag is therefore ignored.
I had to do this as I needed other fields besides the {title} tag, and the category archive tag wasn’t working out for me.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.