Hello and welcome, abirduphigh

I'll try to clarify your doubts -
First, does "template" explicitly refer to anyfile.php or the instance of <cms:template> in a php file?
Template, in Couch parlance, is always a .php file. To be more specific,
a template is a Couch managed .php file that is accessed through the browser explicitly using its name.
For example, a typical site will consist of several such templates e.g. index.php, blog.php, contact.php etc.
These files are accessible by their names e.g. as
http://www.yoursite.com/index.phphttp://www.yoursite.com/blog.phphttp://www.yoursite.com/contact.phpand hence are the 'templates'.
If you go through our tutorial (
http://www.couchcms.com/docs/tutorials/portfolio-site/) this will become clear.
You'll also find there that a template can contain within itself embedded snippets e.g. blog.php internally could contain 'header.php' and 'footer.php'. These snippets are also files but
are not considered templates as you'll never access them directly as e.g.
http://www.yoursite.com/snippets/header.phpMoving further -
Every template (and only template) contains the
<?php require_once( 'couch/cms.php' ); ?>
<?php COUCH::invoke(); ?>
statements.
So, in our example, index.php. blog.php and contact.php, all three will have the two PHP statements. But header.php and footer.php will not.
Once we place the above statements in a template and visit it once as super-admin, Couch registers it and shows it in the admin-panel's sidebar.
So, another hallmark of a template is that it appears in the admin-panel's sidebar.
Hopefully that clears things up a little bit.
Now I'll address the specific confusion that you have.
I'll continue with the example site I mentioned above.
So we have index.php. blog.php and contact.php and since these are accessible as URLs, these are our templates.
Which means each of the three file has the <?php require_once( 'couch/cms.php' ); ?>..<?php COUCH::invoke(); ?> statement in it.
Which again means that the three appear as distinct entries in the admin-panel sidebar.
Now if we were to define editable regions (<cms:editable>) in the three templates, we'll see those in the admin-panel (clicking, for example, on contact in sidebar will reveal all editable regions defined in it).
I think all the above said points should be clear enough.
Now consider what happens if we do this -
If we edit the 'index.php' template, and place the following statements in it -
- Code: Select all
<cms:pages masterpage='blog.php' limit='5'>
<h3><cms:show k_page_title /><h3>
</cms:pages>
<cms:pages masterpage='contact.php' limit='1>
<h3><cms:show k_page_title /><h3>
</cms:pages>
What will happen is - when we access the index template (as for example
http://www.yoursite.com/index.php or simply
http://www.yoursite.com/), it shows us the data from the blog and contact template.
Do you get the point above?
In Couch
we can show data belonging to any template (e.g. blog.php)
on any other template (e.g. in index.php above).
So although blog.php and contact.php are templates, just like index.php, we can always show their data on index.php (or, conversely, we can show data from index.php on contact.php if we so want).
We can use this property to create single-page sites.
In fact, the code we placed in index.php above has already turned our site into a single-page application (as a single template index.php is showing data from all other templates).
The only hitch above could be that the blog and contact templates can be accessed directly via URLs e.g.
http://www.yoursite.com/contact.php, which won't be desirable as we are creating a single page site.
Though we cannot completely prevent a template from being accessed through URL (as that is the very definition of a template) what we can do is prevent non-admins (i.e. normal visitors) from doing so.
To do this, we edit blog.php and contact.php and add the following code within them
<cms:template executable='0'>
</cms:template>
Doing this makes them off-limit to general public.
The cms:template tag above can be placed in any template (and only template) and is used to set certain properties of the the template e.g. the following if placed in some template will make the template clonable, commentable and make it appear as 'Products' in the admin-panel sidebar -
- Code: Select all
<cms:template title='Products' clonable='1' commentable='1'>
</cms:template>
I hope this would make the concept behind single-page site clear to you.
Please let me know if this helped.
Thanks.