Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
I am trying to write an 'if' statement based on the number of pages in a template. Specifically, I have an "Events" template with several events. I am trying to write the conditional so that 'if the number of Event pages is greater than 3, then show a "view more" button'. The caveat is that I'm trying to accomplish this on the index page, rather than the template page. I have already called
Code: Select all
<cms:pages masterpage='events.php'>
and used a separate 'if' statement that functions properly. k_page_folderpagecount and k_folder_folderpagecount do not work in this instance.

This seems like a very basic/easy thing to achieve, but I cannot find anything in the docs that works. Any help is appreciated.


The <cms:pages> with the 'masterpage' parameter can be used anywhere on the site and will function exactly the same; so no issues in using it on the index page.

Please try the following -
Code: Select all
<cms:pages masterpage='events.php' limit='3'>
    <h2><cms:show k_page_title /></h2>

    <cms:if k_paginated_bottom >
        <cms:if k_total_records gt '3'>
            <a href="<cms:link 'events.php' />">View more..</a>

The code above displays only three pages but in the <cms:if k_paginated_bottom > block (which executes only when the last, in this case the third, page is being shown) we check the total number of pages in the template and display the view more button accordingly.

Is this what you are trying to achieve?
If not, I'd suggest you place a <cms:dump /> tag within the <cms:pages> block and you'll get to see all the variables available for use. I am sure you'll find the one that'll help in your use-case.
2 posts Page 1 of 1

Who is online

In total there are 6 users online :: 1 registered, 0 hidden and 5 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Google [Bot] and 5 guests