Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hi all,

Really enjoying working with Couch CMS but I'm having a bit of difficult time try grasp which of the core concepts I should use to create the following.

Basically I have an about section of the website I am currently building, this consists of any number of cloned pages. This is all fine and I have my three page (client will need the ability to add more pages using the same template to this view on the website) but instead of showing a listings page when the user goes to /about.php I want it to default to a specified cloned page.

For example I have the following page structure:

Code: Select all
About
    - About this website
    - About this business
    - About the city


in the main navigation for the site there will be a link to "about", when the user clicks this link or visits /about.php I want it direct them to the "about this website" page (which is the default page in backend) instead of the listings view. Is this possible? I just having a bit of difficulty trying to figure out what the best way to go about doing this.

I currently have all the pages there and can access them with the /about.php?p=## url but how do I go about defaulting the first page in that list to appear when the link is just /about.php ?

Here's a basic version of what I am trying to achieve

Code: Select all
<cms:template title='About' clonable='1'>
   <cms:editable name="about_content" type="richtext" />
</cms:template>
<html>
    <head>
        <title>about</title>
    </head>

    <body>
        <!-- Primary Content -->
        <main>
            <cms:if k_is_page>
                <article>
                   <div>
                        <h1><cms:show k_page_title /></h1>
                    </div>
                    <div>
                        <cms:show about_content />
                    </div>
                </article><!-- /article -->
                <cms:else />
                        here <!-- this is where I want the first item in the navigation below to be displayed if a page isn't loaded -->
                </cms:if>
            </main>

        <!-- About section in page sub navigation widget -->
        <aside>
            <ul>
                <cms:pages masterpage='about.php' order="asc">
                    <li><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></li>
                </cms:pages>
            </ul>
        </aside>
    </body>
</html>


Thanks in advance for any help anyone may be able to provide.
hi there, this is similar to something I've done on previous Couch websites, when I didn't want to show a listing of the cloned pages, just go straight to the first cloned page from the main nav link. At the top of the HTML just underneath the <body> tag try putting:

Code: Select all
  <cms:if k_is_list >
            
   <cms:pages masterpage='about.php' limit='1' orderby='?????' order='asc' >
   
      <cms:redirect url=k_page_link />
                   
   </cms:pages>
 

  </cms:if>


And within the main navigation:

Code: Select all
            <cms:set current_template_name=k_template_name />
            
            <cms:pages masterpage='about.php' limit='1' orderby='????' order='asc' >
            
               <li><a href="<cms:show k_page_link />"<cms:if k_template_name==current_template_name> class="current"</cms:if>>About</a></li>
                            
            </cms:pages>


It may be better accomplished using nested_pages -a tag I haven't used ... I'm sure somebody better qualified will advise if that is the case!

Good luck!
@potato,
Since in the list-view we are already redirecting to a page, the code for setting the link in navigation is actually redundant (although it'll certainly work).
A normal link to the list-view will work just the same - e.g.
If this could be the link to the main page -
Code: Select all
<a href='<cms:link 'about.php' />'>About Us</a>

when a visitor clicks on the link above, she'll be redirected to the first page found by the code you posted -
Code: Select all
<cms:if k_is_list >
    <cms:pages masterpage='about.php' limit='1' orderby='?????' order='asc' >
        <cms:redirect url=k_page_link />
    </cms:pages>
</cms:if>

or if the page to be redirected is fixed the code above could be made a little simpler as follows -
Code: Select all
<cms:if k_is_list >
    <cms:redirect url="<cms:link masterpage='about.php' page='about-this-website' />" />
</cms:if>
That works perfectly, cheers.

I thought there may have been a way to display the CMS default page when visiting /about.php and then the subpage when viewing, for example, /about.php?p=1 but this solution has worked perfectly!

Thanks again!
You are welcome :)
5 posts Page 1 of 1
cron