Forum for discussing general topics related to Couch.
6 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.
6 posts Page 1 of 1

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest