Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I have been teaching myself couch through the tutorial, and i have arrived at a dilemma. In the tutorial you demonstrate how to automatically show the active link using this code.

Code: Select all
<li><a href="<cms:link 'index.php' />" <cms:if k_template_name=='index.php'>class="active"</cms:if> >Home</a></li>


Now i have tried and tried to make it dynamic for pages within the template. This is what i have:

Code: Select all
<cms:pages masterpage='index.php' limit='10' order='ASC' paginate='1'>
<li>
   <a href="<cms:show k_page_link />" <cms:if k_page_name=='k_page_name' > class="active" </cms:if> > <cms:show k_page_name />   
        </a>
</li>   
</cms:pages>


Can someone please help. I am trying to populate a navigation with content from clonable pages within the index template.
Hi,
Please try the following code -
Code: Select all
<cms:set my_current_page=k_page_name 'global' />

<cms:pages masterpage='index.php' limit='10' order='ASC' paginate='1'>
<li>
   <a href="<cms:show k_page_link />" <cms:if k_page_name==my_current_page > class="active" </cms:if> > <cms:show k_page_name />   
        </a>
</li>   
</cms:pages>

Please note that in the code above we first save the current page's name in a global variable because within cms:pages the k_page_name variable will contain the names of the pages being listed.

Hope this helps.
Thank you so much. That solution has worked.

Please let me bother you some more as i want to learn how to code with couch before I take up an upcoming project. I am trying to create 2 different outputs in a cloned page using the name of my dynamic folders as my valuable here is my code:

Code: Select all
<cms:if k_is_page > 
<HTML MARK UP >
  <cms:pages folder=k_folder_name>
        <cms:if k_folder_name = 'NOT teamview' >
      <cms:embed 'normal.tpl' />
   <cms:else />
      <cms:embed 'thumb.tpl' />
   </cms:if>     
  </cms:pages>
<HTML MARK UP >
<cms:else />
   <cms:embed 'home.tpl' />
</cms:if>
3 posts Page 1 of 1
cron