Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hello -

I have a page that lists the titles of folders (that have subfolders). What I'd like is to NOT list those titles (of the root folders) that have empty sub-folders. Here's the code I'm using now:

<cms:folders masterpage='portfolio.php' hierarchical='1' depth='1'>
<div class="catagory_1 clearfix">

<!-- Row 1 -->
<div class="grid_3 textleft" >

<h9 class="title" margin-left:20px><cms:show k_folder_title /></h9>
<p></p>
<cms:pages masterpage='portfolio.php' folder=k_folder_name include_subfolders='1' limit='1'>
<cms:set var_glo_ft=k_folder_name scope='global' />
<h8 class="title" margin-left:20px><a href="portfolio_flist.html"><cms:show k_page_foldertitle /></a></h8>
</cms:pages>

</div>


<div class="grid_9">

<cms:pages masterpage='portfolio.php' folder=k_folder_name>
<cms:if sold = 'No' >
<a class="portfolio_item float <cms:zebra 'alpha' '' 'omega' />" href="<cms:show k_page_link />">
<span><cms:show k_page_title /></span>
<img class="" src="<cms:show thumb />" alt=""/>
</a>
</cms:if>
</cms:pages>
<div class="clear"></div>
</div>

</div>
<p></p>

<div class="hr grid_12 clearfix">&nbsp;</div>
</cms:folders>
Hi,

The cms:folders tag (as almost all tags that are not self-closing) sets variables pertaining to each folder as it iterates through them. These variables include one that give us the count of pages contained immediately within the folder (k_folder_pagecount) and another that gives us a total of all the pages contained within the folder and all its sub-folders (k_folder_totalpagecount)

We can use the second variable mentioned above to target folders that have pages below them. A sample code could be -
Code: Select all
<cms:folders>
    <cms:if k_folder_totalpagecount>
        ... this folder has pages beneath it ..
    </cms:if>
</cms:folders>

HINT: You can always place a <cms:dump /> tag inside any tag to see all the variables (with values) that become available.

Hope this helps.
You are the best! SO IT COUCH CMS!
You are welcome :)
4 posts Page 1 of 1