Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hello, first of all thank you very much for creating such an amazing cms and a perfect tutorial which made me have my portfolio website so easily.

My question is this: I've embedded my footer to the pages with the embed code of Couch. The footer is in the snippets folder as you know. However, I can't get the footer to be content managed by using the regular way that was explained in the documentation. I want to manage the content of the footer within couch cms and I want my change to take effect on all the pages since I'm using the same footer as an embed snippet on each page. Thanks in advance.
Hi and welcome @Sensible

We can use the values stored in one template in any other template. You could create a globals template which would hold any common fields:
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Global Settings' executable='0'>
   <cms:editable name='footer' type='text'/>
</cms:template>
<?php COUCH::invoke(); ?>

Then in your snippets you could retrieve any of this template's values like so:
Code: Select all
<cms:get_custom_field 'footer' masterpage='globals.php'/>
Thank you very much for the answer. I'm just having some hard time understanding.

Let's say I have an index file and an embed footer with the index. Index is also the portfolio page. What am I gonna do now? Sorry for the inconvenience.
Hi,

Please allow me to try and explain -

Suppose your site consists of only three templates - index.php, about.php and portfolio.php.
Also suppose that your snippet in question is named 'footer.html'.
Now all the three templates mentioned above will contain the following code to share the footer snippet
Code: Select all
<cms:embed 'footer.html' />

To make the contents of 'footer.html' dynamic (i.e. capable of being entered/updated from the admin panel), please create a fourth template, as @cheesypoof explained, named 'globals.php'. We'll use this to create editable regions the values of which will be used globally across templates (like the footer text, for example).

Following is the exact text that you can put in the new 'globals.php' template
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Global Settings' executable='0'>
   <cms:editable name='footer' type='text'/>
</cms:template>
<?php COUCH::invoke(); ?>

Please notice that we are defining only a single editable region ('footer') in our template. If need arises you can add new regions to it (e.g. Site's name, slogan, email address etc.).

Go through the usual process of registering the template by accessing it as super-admin in browser. Once the template becomes available in the admin-panel, put whatever text you require in the footer inside the editable region and save.

Now to use the text we inputted above in our footer snippet (assumed to be 'footer.html'), please edit footer.html to place the following code within it -
Code: Select all
<cms:get_custom_field 'footer' masterpage='globals.php'/>

As you can see, we are simply retrieving the value from 'footer' editable region of 'globals.php'.

This should be it. Since the same footer snippet is shared across all the three templates, the inputted value should become visible in all the three.

Hope I was able to explain myself :)
Please feel free to let us know if something is still unclear.
Thanks.
4 posts Page 1 of 1