Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hi
First let me say as newbie to the forum that I've been working with a variety of CMSs for 15 years and Couch beats them all - I love it. It's even better than the CMS we wrote from scratch ourselves!

There's something I can't figure out how to do to and I've searched hard for the answer and tried various techniques before posting this.
I want every page of my client's site to display a testimonials slider in a side box.
Obviously I can include this as a repeatable on every page but that's hardly ideal from a site management viewpoint.
I would like instead to have the testimonials template managed by the client via the CMS and be able to embed it anywhere I wish, including in a sidebar on the blog page.
It would be similar I guess to <?php include...
I've tried 'embed' but that doesn't do it. I've tried 'master page' but haven't been able to get that to work either.
I simply want to be able to directly display the repeatable I have setup in 'testimonials.php' on any other page.
Thanks in advance for your help
Hi Chris :)

Thank you for appreciating our little CMS. I am glad you found it useful.

Regarding the use-case you mentioned, the plan of action that you chalked out is precisely what is needed to handle it most efficiently. I think something is going wrong in actually implementing it so allow me to lay it out step-by-step.

1. Create a separate template (non-clonable), say named 'global.php'. Define within this template a repeatable-region, say named 'testimonials'. Register the template the usual way and then fill the repeatable region with some sample testimonial data.

2. We now need to display the data from the 'global.php' template above within all the pages of the site. All the pages would actually mean "all the templates" used by the site. To begin with, let us target only one of the templates - let us say we choose 'index.php'. Try placing the following somewhere within it -
Code: Select all
<cms:pages masterpage='global.php' limit='1'>
    <cms:show_repeatable 'testimonials' >
        <cms:dump />
    </cms:show_repeatable>
</cms:pages>

You should see the data from 'testimonials' repeatable-region defined in 'global.php' being dumped within index.php.
Obviously, instead of the <cms:dump />, you can now display the correct variables with the proper formatting.

3. Once the step above works, you can copy/paste the same code in all the other templates of your site and the code should work exactly the same as within index.php.

This is a perfectly valid approach but has one little problem - if at any point you decide to make any changes to the code above, you'll now need to make that change in all the templates where the code was pasted.

To get around this, a better approach would be to paste the code into a separate file, say named 'my_testimonials.html' and place that file into your site's snippets folder (which, unless changed from config, is the 'couch/snippets' folder).

And now, in all the templates of your site, remove the original full code and instead place the following single line of code -
Code: Select all
<cms:embed 'my_testimonials.html' />

This should display the testimonials in exactly the same fashion as with the full code actually pasted within each template.
But now, if you have to make any changes, you can do that to one single location i.e. the 'my_testimonials.html' snippet and it would reflect everywhere the snippet has been embedded.

Please try the steps I outlined and let me know if it helped.
Many thanks for the detailed and comprehensive reply.
Your solution worked immediately.
I had somehow managed to
1) neglect to add limit='1'
2) place one of my cms statements outside of the slideshow processing loop.

It's now working perfectly. Thank you again for your help.
3 posts Page 1 of 1