Forum for discussing general topics related to Couch.
9 posts Page 1 of 1
Hi Everyone,

First of all thanks Couch by the way for following me back on Twitter!

I've just started with Couch and I've had fun learning all of its features and code.

I've recently wanted to create a list of pages on a page that does not the include the current page. i.e. something like

Code: Select all
<cms:pages masterpage='blog.php' id='NOT (the current page)'></cms:pages>


How would I go about doing that? Bonus if I can do this with random!

Regards!
Hi and welcome to our forums, Jon :)

Replying to the query you have -
you were very close to getting it done. This is how we can exclude the current page:
<cms:pages id="NOT <cms:show k_page_id />" ></cms:pages>

The trick is to use double-quotes with a parameter and then we can use any Couch code within it. In our case we are simply outputting the current page's ID (I trust you are using this snippet on a page-view else there won't be a page to get the k_page_id for).

The randomze the listing, simply add the orderby parameter like this:
<cms:pages id="NOT <cms:show k_page_id />" orderby='random' ></pages>

Hope this helps :)
Aw, thanks KK! I just got scared to nest the cms tags! I should really experiment!

[edit] And yes, I have taken to using snippets. A little retro-fitting but worth it. No more "includes"ing!
This isn't working for me :( What am I doing wrong?

Code: Select all
<cms:pages masterpage='blog.php' id='NOT <cms:show k_page_id />' orderby='publish_date' limit='10'>
  <article class="archive-content-block">
    <!-- <cms:dump/> -->
    <h3 class="archive-title"><a href="<cms:show k_page_link/>"><cms:show k_page_title/></a></h3>
    <div class="archive-content">
        <!-- <cms:show k_page_id /> -->
        <cms:excerpt count='20'><cms:show blog_article/></cms:excerpt>
        <div class="more-link-wrapper">
            <a href="<cms:show k_page_link/>" class="more-link">More <i class="fal fa-arrow-right"></i></a>
        </div>
       
    </div>
  </article>
</cms:pages>
pls disregard, replied to wrong post.
Hi,

Little bump on this old post :-)

So, I can't find how to make an exclusion for the current page that is being displayed.
Basically I have a clonable "portfolio.php" page. Each cloned page is associated with a k_folder.

I want to show, at the end of each page, a list of all items related to the current visible item's k_folder. It's working fine but It's showing literally all items, and I want to exclude the current k_page_id - as it's already being seen and it's not "related" :)

This html section is:

Code: Select all
<section id="k-houses-related">
   
   <div><h3>more on <cms:show k_page_foldertitle /></h3></div>

<cms:if k_page_folderpagecount gt '0' >
<div class="main-carousel-related">
      <div class="carousel-cell">
            <div class="thumb">
               <img src="<cms:show thumbnail_img />" alt="">
            </div>
            <div class="txt">
               <h4><cms:show k_page_title /></h4>
               <h5><cms:show project_location /></h5>
            </div>
      </div>      
   </div>
</cms:if>   
</section>
@francisknightley, I don't see a <cms:pages> loop anywhere in the code you posted; are you sure this is the exact code you are using? I don't expect it to display anything but the current page.
@KK

Oooops so many years using this and sometimes I still forget about small ridiculous stuff :shock:
Again thanks for rocking hard on the forum helping everyone out 8-)
9 posts Page 1 of 1