Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Not sure if the tags should be folders or pages, etc. This particular module needs to show links in a folder that the page is part of. E.g On animation page, sidebar shows all the work in the animation folder.

This is my code:

<div class="rightlinks">
<ul>
<cms:folders masterpage='work.php'>
<li><a href="<cms:show k_page_folderlink/>"><cms:show k_page_foldertitle/></a></li>
</cms:folders>
</ul>
</div>
</div>
Hi,

The 'folders' tag, as its name suggests, is used to list the folders while it is the 'pages' tag that is used to list the pages.
The 'pages' tag accepts several parameters that can be used to constrain the pages it fetches (see: http://www.couchcms.com/docs/tags-reference/pages.html) of which 'folder' is what we need to use for what you require.

Code: Select all
<ul>
   <cms:pages masterpage='work.php' folder=k_page_foldername limit='5'>
      <li><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a></li>
   </cms:folders>
</ul>


k_page_foldername is a variable that is made available by Couch to denote the containing folder of the current page. By setting the 'folder' parameter to this variable we constrain the listing to include only pages from the current page's folder.

We need to keep in mind that 'k_page_foldername' is set only in page-view (i.e. when a single page is being displayed). So in other views (home, folder-view etc.) this variable will be blank and the code above will fetch the top 5 pages belonging to 'work.php' ignoring any folders.

If you want to display the list only in page-view, add the following check
Code: Select all
<cms:if k_is_page >
   <ul>
      <cms:pages masterpage='work.php' folder=k_page_foldername limit='5'>
         <li><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a></li>
      </cms:folders>
   </ul>
</cms:if>


Hope this answers your question.
Think you may have mistyped but here's what I tried:

Code: Select all
             <cms:if k_is_folder>
             <div class=rightbox>
                <div class=rightboxtop></div>               
                    <div class=rightarea>
                    <h2><cms:show k_folder_title/></h2>
                    <div class=divider></div>
                    <div class="rightlinks">
                        <ul>
                        <cms:pages masterpage='work.php' folder=k_page_foldername>
                             <li><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a></li>
                        </cms:pages>
                         </ul>
                     </div>
                    </div>
                <div class=rightboxbot></div>               
             </div>
            </cms:if>


The <cms:if k_is_folder> yield the right appearance of the module. Did you mean <cms:folders ... or <cms:pages...>? Folders didn't yield anything while pages yield all the works regardless of which category the works came from.
I think I really must get a prolonged session of sleep now :)

You are right, I messed with that ending tag. It was supposed to be 'pages'.
Anyways, you can use any of the following snippets that suits your need.

1. Show a list of latest 5 pages belonging to the folder being shown in folder-view (i.e. if visiting 'animation' folder, show 5 pages that belong to 'animation') -
Code: Select all
<cms:if k_is_folder>
<ul>
  <cms:pages masterpage='work.php' folder=k_folder_name limit='5'>
    <li><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a></li>
  </cms:pages>
</ul>
</cms:if>

2. Show a list of latest 5 pages belonging to either the folder being shown in folder-view (i.e. if visiting 'animation' folder, show 5 pages that belong to 'animation') or belonging to the containing folder of the page being shown in page-view (i.e. if visiting page 'chicken-scratch.html' that is within 'animation' folder, show 5 pages from 'animation') -
Code: Select all
<cms:if k_is_folder || k_is_page>
   <cms:if k_is_folder><cms:set my_folder=k_folder_name /></cms:if>
   <cms:if k_is_page><cms:set my_folder=k_page_foldername /></cms:if>
   <ul>
   <cms:pages masterpage='work.php' folder=my_folder limit='5'>
      <li><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a></li>
    </cms:pages>
   </ul>      
</cms:if>

Notice how in the code above we are using 'k_folder_name' for folder-view and 'k_page_foldername' for page-view.

Hope this helps. Do let me know.
4 posts Page 1 of 1