If I am ging to use includes to control menus, headers, footers and the like, can I use Couch CMS to change these files so that they change universally across the site? If so, how would that work?
1. You can keep on using the original PHP way of including files e.g.
<?php include("menu.php"); ?>
2. or (preferably) use Couch's cms:embed tag to do the same (you'll have to move the 'menu.php' to the 'snippets' folder) e.g.
<cms:embed "menu.php" />
Coming to your question -
..can I use Couch CMS to change these files so that they change universally across the site?
"use Couch CMS to change these files" - if by this you mean be able to modify the markup code contained within the included files from within the Couch admin panel, the answer is yes you can. Here is how -
Create a template, say named 'globals.php', and make it non-executable because we'll use it only to store the code for our included files (i.e. globals.php will never be accessed via its URL by th world at large)
- Code: Select all
<cms:template executable='0' >
</cms:template>
and then create editable regions (of type textarea) for each of your include files. Make sure to set the no_xss_check to '1' to prevent Couch from sanitizing the HTML code entered within it. e.g.
- Code: Select all
<cms:template executable='0' >
<cms:editable name='menu_code' label="Menu code"
height='100'
no_xss_check='1'
type="textarea"
/>
<cms:editable name='footer_code' label="Footer code"
height='100'
no_xss_check='1'
type="textarea"
/>
</cms:template>
Visit globals.php while logged-in as super-admin for Couch to pickup the changes.
In the admin panel you can now add the HTML code for each of the previously included files into their respectable editable regions.
To include the code entered within the editable regions created above into the rest of the templates of your site, use the cms:get_custom_field tag. e.g. change the
- Code: Select all
<?php include("menu.php"); ?>
or
<cms:embed "menu.php" />
- Code: Select all
<cms:get_custom_field 'menu_code' masterpage='globals.php' />
Hope this answers your query.