Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Am just glancing over my latest site and thinking about how to Couch it - this one has a very simple sub menu. So, one of the main links is 'Concerts' - click on that link and we go to a sub-page showing Concert No.1. There are 7 Concert sub-pages each with a simple vertical sub-nav list showing Concerts 1-7.

My question is should I plunge into Menu Maker or can I stick to Cloned pages? Obviously Menu Maker sounds like the correct route to go semantically ... but Cloned pages might be quicker and easier?
Menu maker really shines when there is a complex hierarchy of pages to be represented by the menu.
For simpler arrangement of pages, you can choose not to use it.
I am showing a list of cloned pages as a simple sub navigation list

Code: Select all
 <cms:pages masterpage='concerts.php' orderby='concert_no' order='asc' >
<li><a  href="<cms:show k_page_link />"><cms:show k_page_title /></a></li>
</cms:pages>


Is it possible to identify 'current' page being shown somehow?

I can't see a way of identifying a cloned page's identity dynamically - and leaving current page unhighlighted isn't great for the site's users :(
Since this will be implemented on the page view, we have many variables available to make this work. We could use either k_page_id or k_page_name to accomplish this, as they all are unique. I will choose the latter for this example, it really doesn't matter though which you choose to use. We first set the current page name to a variable: current_page_name.
Code: Select all
<cms:set current_page_name=k_page_name />
We can then use this variable within the 'pages' tag. As the 'pages' tag iterates through all your cloned pages, it will check each time whether or not the page being listed is a match for the current page.
Code: Select all
<cms:pages masterpage='concerts.php' orderby='concert_no' order='asc' >
<li><a href="<cms:show k_page_link />"<cms:if k_page_name=current_page_name> id="current"</cms:if>><cms:show k_page_title /></a></li>
</cms:pages>
I once asked this same question also. ;)
http://www.couchcms.com/forum/viewtopic.php?p=4845#p4845
hi cheesypoof - just stepped back in to my office having printed off the documentation on 'Nested Pages (AKA Menu Maker) and been sitting outside in the sunshine reading it, wondering if this is what I should be doing with my site. I have to say Nested Pages looks a fantastic feature, but for me, as a Couch beginner, fantastically complicated (this is no criticism of the documentation - which as ever, is clear and detailed, like having someone telling you in a classroom - just a statement of my level of Couch competence!).

Thanks for your help on this - I willl try it out after lunch and post back again to confirm success (will also read the post you refer to)! There is loads of really good stuff in the forums - sometimes it's hard to find what you are looking for. Perhaps, if the Couch team ever have time, a separate section in the documentation - "Couch How Tos" - would be a bonus!

Onward and upward :)
Yes, the current link for the sub nav is working! Thanks.

BUT, I've now got a problem with the main navigation link for Concerts - it is always highlighted as 'current'. I've tried <cms:dump /> to enlighten me, but it looks OK e.g. on any other main page k_template_name is not 'concerts.php' - so I wouldn't have thought the class of 'current' should therefore be applied to concerts, but it clearly is.

Code: Select all
<cms:pages masterpage='concerts.php' limit='1' orderby='concert_no' order='asc' > 
            
<li><a href="<cms:show k_page_link />"<cms:if k_template_name=='concerts.php'> class="current"</cms:if>>Concerts</a></li>
                
</cms:pages>        


All a bit confusing and I'm going round and round in circles - I don't think I can work this one out on my own. Most grateful for any input ...
Would you mind granting me FTP/Couch access to your site for a little while please?
I'll want to take an overall view of the way you have organized your site to propose a solution.
Don't worry, I am sure the solution would be pretty simple.

Thanks
Potato, as KK said more information would be helpful. From what I can gather though you are trying to get the main Concerts navigation link to have class="current" when you are either viewing a cloned concerts page or on the concerts home/list view, but not when you are viewing a different template. Your code will not function as constructed for this purpose. The reason why is because since you chose concerts.php as your masterpage for the 'pages' tag, the k_template_name variable inside of the 'if' tag will always be concerts.php. This creates a situation where the 'if' tag will always output class="current". This is the reason why in reply to your first question I used the 'set' tag to get around this sort of problem. If you used a similar method of setting a variable before the 'pages' tag, your code would work.

Nevertheless, in this case since we are only trying to create one navigation link for Concerts, the 'pages' tag is not necessary. The following code should suffice:
Code: Select all
<li><a href="<cms:link 'concerts.php' />"<cms:if k_template_name=='concerts.php'> class="current"</cms:if>>Concerts</a></li>

Keep in mind that since this was not wrapped in a 'pages' tag, the k_template_name variable in this instance returns the genuine template name of the page you are viewing. No 'set' tag is required consequently. I hope I haven't misunderstood what you are trying to accomplish.
hello again, thanks for your replies, sorry for the rather inadequate information, I think I was feeling a bit frazzled with it at that stage. The site is not live yet - am working on localhost - so I'll have to explain in a bit more detail ...

I have a main menu which includes a link = CONCERTS. CONCERTS is the only page on the site with sub navigation. There is no drop down navigation - it is a simple vertical list of 7 concert dates shown on each of the 7 concert cloned pages.

So to keep things as simple as possible (for me) I chose to go down the cloned pages routes (rather than nested pages/menu maker). I created a template - concerts.php (copied at the bottom of this post) and generated 7 cloned pages from this. I am not interested in the LIST view of the concerts.php page - since clicking on the main menu link CONCERTS will take you to the first cloned page. There is nothing to go on the listing page.

I am embedding the main_nav.html snippet as follows:

Code: Select all
<ul>              
   <li><a href="<cms:link 'index.php' />"<cms:if k_template_name=='index.php'> class="current"</cms:if>>Welcome</a></li>         
   
       <cms:pages masterpage='concerts.php' limit='1' orderby='concert_no' order='asc' >
   
      <li><a href="<cms:show k_page_link />"<cms:if k_template_name=='concerts.php'> class="current"</cms:if>>Concerts</a></li>
       
   </cms:pages>                
   
   <li><a href="<cms:link 'artists.php' />"<cms:if k_template_name=='artists.php'> class="current"</cms:if>>Artists</a></li>
   <li><a href="<cms:link 'venues.php' />"<cms:if k_template_name=='venues.php'> class="current"</cms:if>>Venues</a></li>
   <li><a href="<cms:link 'tickets.php' />"<cms:if k_template_name=='tickets.php'> class="current"</cms:if>>Tickets</a></li>
   <li><a href="<cms:link 'support-the-festival.php' />"<cms:if k_template_name=='support-the-festival.php'> class="current"</cms:if>>Support us</a></li> 
   <li><a href="<cms:link 'directions.php' />"<cms:if k_template_name=='directions.php'> class="current"</cms:if>>Directions</a></li> 
   <li><a href="<cms:link 'your-visit.php' />"<cms:if k_template_name=='your-visit.php'> class="current"</cms:if>>Your visit</a></li> 
   <li><a href="<cms:link 'contact.php' />"<cms:if k_template_name=='contact.php'> class="current"</cms:if>>Contact</a></li>              
</ul>


This is functioning correctly in that clicking the main CONCERTS link takes you to the first cloned concerts.php page. And the sub-navigation is working OK too (thanks to Cheesypoof).

BUT the main nav link CONCERTS is permanently set as current link (along with the other page link e.g. on the home page both HOME and CONCERTS are 'current').

I guess that I can set the concerts.php template to executable=0 so that if a user tries to access it they'll get a 404 error.

I'm keen to crack this as I think it'll provide the basis for quite a lot of sites I do - fairly simple with no real need for complex nested lists for navigation purposes.

Am really very grateful for your help!

concerts.php

Code: Select all
<?php require_once( 'hhcmf/cms.php' ); ?>
<cms:template title='Concerts Page' clonable='1' commentable='0' order='15' >

<cms:editable name="concert_no" label='Concert Number (for ordering in navigation)'  type='text'  order='5'/>

<cms:editable name="concert_date_time" label='Concert date and time'  type='text'  order='10'/>

<cms:editable name="concert_venue" label='Concert venue'  type='text'  order='15'/>

<cms:editable name="featured_artist" label='Artist performing'  type='text'  order='20'/>

<cms:editable name="artist_extra" label='Artist extra info'  type='textarea'  order='25'/>

<cms:editable name="concert_programme" label='Concert programme'  type='textarea'  order='30'/>

<cms:editable name="concert_details" label='Concert details (e.g. like Bows and Arias)'  type='richtext'  order='35'/>

<cms:editable name="ticket_info" label='Ticket info'  type='text'  order='40'/>

<cms:editable name="ticket_info_supplementary" label='Ticket info supplementary'  type='text'  order='45'/>

<cms:editable name='festival_brochure' label='Festival Brochure' desc='Upload the file here' type='file' order='50'/>

<cms:editable name="concert_thumbnails" label='Concert thumbnails'  type='richtext'  order='60'/>

</cms:template>

<!doctype html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title></title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <cms:embed 'upgrade_prompt.html' />
 
  <div id="site-container" class="clearfix" role="main">
   
       <h1 class="main-heading">Hatfield House Music Festival</h1>
       <h2 class="date-of-festival">20th-23rd September 2012</h2>
   
       <div id="main-nav">
         <cms:embed 'main_nav.html' />
       </div>
       <br class="clear-both" />
         
         
      <div id="sub-nav-container">
         <ul id="sub-nav">               
              
          <cms:set current_page_name=k_page_name />
                
          <cms:pages masterpage='concerts.php' orderby='concert_no' order='asc' >                     
         
            <li><a href="<cms:show k_page_link />"<cms:if k_page_name=current_page_name> class="current"</cms:if>><cms:show k_page_title /></a></li>
             
         </cms:pages>
       
      
         <a href="<cms:show festival_brochure />" target="_blank" ><img class="float-left" src="img/brochure-download.gif" width="119" height="62" alt="brochure download"/></a>
       
   
       </div>
      
      
 
    <div id="left-column-concerts">
       <div class="concert-info">
         <h2><cms:show concert_date_time /></h2>
         <h6><cms:show concert_venue /></h6>
         <h3><cms:show featured_artist /></h3>
         <h4><cms:nl2br><cms:show artist_extra /></cms:nl2br></h4>
         
         <cms:if "<cms:not_empty concert_programme />">                        
             <cms:nl2br><cms:show concert_programme /></cms:nl2br>
         </cms:if>         
         
         <cms:if "<cms:not_empty concert_details />">                        
             <cms:show concert_details />
         </cms:if>
         
         <h5><cms:show ticket_info /></h5>
         <p><cms:show ticket_info_supplementary /></p>
         
      </div>
   
    </div>
   
   
    <div id="right-column-concerts">
   
       <cms:show concert_thumbnails />
       
    </div>
   
    <br class="clear-both" />
   
     
<cms:embed 'footer.html' />

</div>


  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>   
  <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
 


  <!-- end scripts -->

<cms:embed 'google_analytics_snippet.html' />
 

</body>
</html>
<?php COUCH::invoke(); ?>
back again ... I have just sat down with my husband (who doesn't build websites, but is very logical) and patiently walked through everything step by step and with reference to the Couch tags for the sub navigation he got it working!

Code: Select all
<cms:set current_template_name=k_template_name />
            
<cms:pages masterpage='concerts.php' limit='1' orderby='concert_no' order='asc' >

   <li><a href="<cms:show k_page_link />"<cms:if k_template_name==current_template_name> class="current"</cms:if>>Concerts</a></li>
                
</cms:pages>


I hope I've got back in time before anyone spends any time on this. You were right the solution was pretty simple (when you know how!)

What I did find confusing earlier was seeing the output from cms:dump and it looking like my code should work OK with the template name = concerts.php .... not sure about this still.

Thanks again.
12 posts Page 1 of 2
cron