Variables available in Views
From what we have read so far, we know that a template can be either clonable or non-clonable.
A clonable template will necessarily have cloned pages associated with it hence it is said to be executing within a page-view when a cloned page of it is accessed while it is said to be executing within a list-view if it is accessed in a stand alone manner.
A non-clonable template always represents one single page and hence it has no such views associated with it.
Depending on whether a template is clonable or non-clonable and upon the view it is being executed in, each time a template is accessed, Couch makes available certain variables that are relevant to the template's state.
For example, when executed in a page-view, a template is used to access a cloned page and hence all that cloned page's data (including all its editable region's contents) are made available by Couch for use by your script.
In contrast, when executed in a list-view, it is not any single page that is accessed and hence no such page specific data is made available. Instead, certain variables that describe the 'list-view' and make it easy for your script to actually 'list' the pages pertaining to the view, are made available.
A complete list of all the variables that become available during the above mentioned conditions are listed below.
For the sake of this example we make use of a template named blog.php that has three editable regions defined within it - my_blog_text, my_blog_image and my_blog_author (these will be made available as variables with the same names. They are shown highlighted below).
The following variables are available in ALL the cases, irrespective of the clonable status of the template and the current view -
NON-CLONABLE TEMPLATE -
If blog.php is non-clonable, the only way it can be accessed is -
- and the available variables are -
CLONABLE TEMPLATE -
If blog.php is made clonable, the different views it can be accessed in and the variables made available in each view are -
In this view, variables giving information about the current page, the containing folder (if the page resides in one) and the contents of the page's editable regions are made available.
The folowing variables carry information about the page in question -
The following variables carry Information about the folder, if the page resides in one -
Finally the contents of editable regions -
In this view, variables giving information about the folder mentioned in the URL are set.
- k_folder_pagecount (Number of pages in the folder)
- k_folder_totalpagecount (Total number of pages, including pages in subfolders)
In this view, variables giving information about the archive's time period (as given in the URL) are set.
- k_folder_pagecount (Number of pages. Remember home view is also the root folder)
- k_folder_totalpagecount (Total number of cloned pages, including pages in subfolders)
IMP. Notice that for cloneable templates, the contents of the editable regions associated with a page are made available only in page view.
Next is Listing Pages