by
KK » Fri May 31, 2013 9:21 pm
Hi,
Physical files (like the snippets you mentioned) cannot be directly editing through Couch.
However, there is an alternative method that can provide this editing facility.
Basically suppose you have an snippet called 'footer.html' and this is how it is being used in any template
- Code: Select all
<cms:embed 'footer.html' />
This is the how the cms:embed tag is most commonly utilized (i.e. with physical snippet files). The cms:tag, however,
also allows passing it the code directly as its parameter (please see
http://www.couchcms.com/docs/tags-reference/embed.html for details).
What we can do is, use a separate template (say named 'snippets.php') and define within it editable regions to hold the code that was contained within the snippet files (i.e. instead of using physical snippet files, we'll be placing their codes within these editable regions).
So, carrying forward our example, the snippets.php template can have the following region instead of the footer.html snippet mentioned earlier -
- Code: Select all
<cms:editable
name='footer'
label="Footer HTML"
height='100'
no_xss_check='1'
type="textarea"
/>
Please notice that the type of the region defined is
'textarea' and its no_xss_check parameter is set to 1. All the code from the footer.html snippet can now be moved into this region.
Finally, to use the code in other templates, the cms:embed statement can be modified to become the following -
- Code: Select all
<cms:embed code="<cms:get_custom_field 'footer' masterpage='snippets.php' />" />
The output should be just the same as using snippet files.
Using this method allows us to edit the snippet codes right from the admin-panel. It'd be a good idea to set the permission on the snippets.php template to super-admin as you wouldn't want the client to mess up with your markup. The template can also be defined as being non-executable (by setting the executable parameter to '0') because it won't be accessed directly.
Hope this helps. Do let me know.
Thanks.