Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi, I want to display how many posts are in a category.

Posts are categorised with relation to the template in blog_category.php.

In my code below achieve that, but I wonder if is there an easier way to do?

The final touch will be a looping through a blog_category.php and generate the li elements like this: https://www.couchcms.com/forum/viewtopic.php?f=2&t=9243&p=19512&hilit=my_events_template_link#p19512


Code: Select all
<cms:set my_events_template_link_category="<cms:link  'blog-post.php' />" />
<div class="category-widget">
     <ul>
              <li><a href="<cms:add_querystring my_events_template_link " category=web-design" />" class="cat-1">Web Design<span><cms:pages masterpage="blog-post.php" custom_field="blog_category=web-design"><cms:set  web_design_count="<cms:show k_total_records />" "global" /></cms:pages><cms:show web_design_count /></span></a></li>
        
              <li><a href="#" class="cat-2">JavaScript<span>74</span></a></li>
         <li><a href="#" class="cat-4">JQuery<span>41</span></a></li>
         <li><a href="#" class="cat-3">CSS<span>35</span></a></li>
     </ul>
</div>

Attachments

You can rewrite that part -
Code: Select all
<li>
    <a href="<cms:add_querystring my_events_template_link " category=web-design" />" class="cat-1">
        Web Design
        <span><cms:pages masterpage="blog-post.php" custom_field="blog_category=web-design" count_only='1' /></span>
    </a>
</li>


Parameter count_only does the required job of outputting the number of records.
Thank You, Anton!

I wasn't aware of that parameter (count_only='1') of "<cms:pages>" tag. :o

I do not find about that In the https://docs.couchcms.com/tags-reference/pages.html.. :?

Where can we found the COMPLETE tag & parameters list in couch:cms ? :D

Have a nice day!
If people would know all tags and their parameters, then me or @KK can't do 'magic' :) Unfortunately for others, documentation is about 3 years out of date.

I learned directly from php code (couch/tags.php as the main source) and other forum threads.
Maybe it is a stupid idea but what if we have some <cms:dump /> like parameter for tags?

For example:
<cms:pages dump_possible_parameters='1' /></cms:pages>

And show us as all the possible parameters for that tag.

Sorry if it is a dumb idea (and maybe lose your magic power ;) )
It seems like a very interesting and not stupid at all idea. However not all parameters are obvious or self-explainable - for example @KK fairly recently added 'adjust' parameter to cms:pages and had a post in forum with explanations what that means and how to use it and how it differs from 'offset' - so listing available params is not enough unless there is a good explanation for each of them.

Everything must be in docs therefore. Also, open couch/tags.php in an editor and find 'function pages' - you'll see how many params are there and not all of them can be used directly with cms:pages tag - some are reserved for cms:related_pages tag and other which depend on cms:pages in functionality. So simple listing is hardly enough.

Your idea can be applied this way - one can override all tags via a single php function and if some parameter like 'dump' or 'help' is present among params passed to a tag - output a help page, listing all params and their description with examples and links to more samples. Once the texts are prepared, anyone can take a step and add such functionality to display a related help page.
6 posts Page 1 of 1