Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Hello folks,
I'm trying to make something for my personal porfolio site, where I have a "classic" Couch template populating pages serving for a basic image gallery made with a repeatable. Within its own template it works just fine, displaying a list of pages, and when clicked I see the listing page with images from repeatable. However, when trying to access pages from another template (with a masterpage set of course) it displays all the results. My question: Am I able to use "page views" technique at another template located at a different folder within the site structure?
Here is the code at the properly working template:
Code: Select all
<!-- listing content -->
<cms:if k_is_list >
<cms:pages>
    <div class="col-md-4 mb-5 text-center">
      <a href="<cms:show k_page_link />" title="<cms:show k_page_title />">
      <img src="<cms:thumbnail gallery_list_image width='600' height='600' />" alt="<cms:show k_page_title />"></a>
      <p class="title mt-2"><cms:show k_page_title /></p>
    </div>
</cms:pages>

<cms:else />
<!-- page content -->
    <div class="col-12 text-center mb-4"><h3><cms:show k_page_title /></h3></div>
    <cms:show_repeatable 'gallery_images'>
    <div class="col-md-4 mb-5 mx-gutter">
   <img src="<cms:thumbnail gallery_image width='600' height='600' />" alt="<cms:show k_page_title />">
   </div>
</cms:show_repeatable>                   
</cms:if>
Hi,

Suppose the repeatable-region is defined in a clonable template named 'gallery.php'.
Each cloned page of this template will have its own copy of the repeatable-region.

Suppose then you visit a page named 'gali' of this template - the URL used contains the info of the template involved (the masterpage) and also the page being invoked. It is easy for Couch to figure out that it is a 'page-view' and it can then fetch in the repeatable-region belonging to that particular page.

Now suppose there is a second template, say named 'portfolio.php', and you wish to show the same repeatable-region (of page named 'gali' from template named 'gallery.php') somewhere in it.

Clearly when you visit portfolio.php (or a page of it) the info that Couch has from the URL would be about portfolio.php and its page and not about 'gallery.php' and its page.

For that to happen we'll have to explicitly provide it the missing info.
One way of doing that is by using the 'masterpage' and 'page_name' params of <cms:pages> e.g.
Code: Select all
<cms:pages masterpage='gallery.php' page_name='gali'>
   .. here you have access to all fields of the page 'gali'...
   .. This is akin to being in a page-view of gallery.php.
</cms:pages>

Another would be to use <cms:get_field> tag which again would require the same params - viewtopic.php?f=5&t=11105

Hope this helps.
2 posts Page 1 of 1
cron