Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hi, my server is setup to allow parsing PHP from HTML pages. Right now, I have couch running from HTML pages. All my webpages share some information in the footer that I get from a single file called footer.php.

What I tried to do was use couch in my footer.php so I could change it's content from within the admin. When I call footer.php into one of my HTML pages that also use couch for editing everything crashes. I tried using the ignore tag without success.

Just in case I am completely throwing everyone off I'll simplify it like this.

My home page:
Uses couch to allow content editing.

My footer page:
Uses couch to allow content editing.

My home page:
Includes the content from the footer page and crashes.


I used this method for years to update my footer content easily in my pages. I just can't get it to work with couch. Is there a way to do this using couch?

Thanks!
Hi :)

Since you have attached Couch to both index.php (i.e. home) and footer.php, both these files have become, in Couch parlance, 'templates'.

Templates are meant to be accessible via browsers as standalone entities e.g. http://yoursite.com/index.php and http://yoursite.com/footer.php and so *cannot* be nested. That would explain why including footer.php within index.php using PHP include does not work.

Incidentally, the discussion above also brings to light a point - it is unlikely that you'd want to access footer.php via browsers as 'http://yoursite.com/footer.php'. Your aim seems to simply use the contents within footer.php in multiple templates without duplication.

For that you should use footer.php as a 'snippet' - which is Couch's equivalent of PHP includes.

Unlike templates, snippets don't need the <?php require_once( 'couch/cms.php' ); ?> and <?php COUCH::invoke(); ?>
So if you copy the contents of your original footer.php (i.e. without the aforementioned two lines of PHP and without any editable regions defined within) into a file named 'footer.html' and keep that file within couch/snippets folder, you can place the following in index.php (and all other templates) to include that snippet -
Code: Select all
<cms:embed 'footer.html' />

So now how do we make the contents of that footer.html editable?

For that please see http://docs.couchcms.com/tutorials/port ... bal-values
In short, if for example you define an editable region named 'copyright' within 'globals.php', you can place either of the following statements within the footer.html snippet and it'll show the values dynamically in all templates that embed it -
Code: Select all
<cms:get_custom_field 'copyright' masterpage='globals.php' />

Code: Select all
<cms:pages masterpage='globals.php' >
    <cms:show copyright />
</cms:pages>

Hope it helps.
Working now. Thanks for pointing me in the right direction. :D
3 posts Page 1 of 1
cron