Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hello KK,
I am attempting to order dynamic folders by their page count and show only the top 5 folders like this:
Code: Select all
<cms:set categories_count='0' />
<cms:folders masterpage="products.php" paginate='1' limit='5' depth='0' orderby="count" order="desc"  >
{
    "id": <cms:show k_folder_id />,
        "attributes": {
            "title": <cms:escape_json><cms:show k_folder_title /></cms:escape_json>,
            "description": "",
            "createdAt": "<cms:date k_page_creation_date format='Y-m-d H:i:s' />",
            "updatedAt": "<cms:date k_page_modification_date />",
            "publishedAt": "<cms:date k_page_date />",
            "isSubCategory": true,
            "slug": <cms:escape_json><cms:show k_folder_name /></cms:escape_json>,
            "products": {
                "data": {
                    "attributes": {
                        "count": <cms:show k_folder_pagecount />
                    }
                }
            },
            "image": <cms:escape_json><cms:show k_folder_image /></cms:escape_json>
            }
}<cms:incr categories_count /><cms:if categories_count!=k_total_folders>,</cms:if>
</cms:folders>


The above code works fine except the limit parameter doesn't work. The limit only works when I add
Code: Select all
hierarchical='1'
parameter to the folders tag. However, this also changes the ordering of the folders. Can you help me with the right way to do this? Thank you
use a combination of the limit attribute and a conditional check inside the loop.
take this line of code as an instance, by following this the loop will run inside all folders but will output only 5 which contain specific ordering..
Code: Select all
<cms:set categories_count='0' />
<cms:set max_limit='5' />

<cms:folders masterpage="products.php" depth='0' orderby="count" order="desc">
    <cms:if categories_count < max_limit>
        {
            "id": <cms:show k_folder_id />,
            "attributes": {
                "title": <cms:escape_json><cms:show k_folder_title /></cms:escape_json>,
                "description": "",
                "createdAt": "<cms:date k_page_creation_date format='Y-m-d H:i:s' />",
                "updatedAt": "<cms:date k_page_modification_date />",
                "publishedAt": "<cms:date k_page_date />",
                "isSubCategory": true,
                "slug": <cms:escape_json><cms:show k_folder_name /></cms:escape_json>,
                "products": {
                    "data": {
                        "attributes": {
                            "count": <cms:show k_folder_pagecount />
                        }
                    }
                },
                "image": <cms:escape_json><cms:show k_folder_image /></cms:escape_json>
            }
            <cms:incr categories_count /><cms:if categories_count < max_limit>,</cms:if>
        }
    </cms:if>
</cms:folders>
2 posts Page 1 of 1