This page uses the default.html template and draws its main content from the content.html file.

Extras 2

Here are some more obscure features that still come in handy for some projects:

Split page names

By default, an embed tag with a value of page[0] will display the complete name of the current page. But if you set up a site with multi-part pages, like main_home, main_contact and clients_references, you can optionally access the individual parts of those names using the SPLIT_PAGE_NAMES_ON setting in config/constants.php. This site specifies an underscore for that setting, so we can easily say that this is the extras (page[0]) page number 2 (page[1]). Or we can say that the complete page name is extras_2 (page[]).

Search content files

Even if you use Contemplate's HTML or XML storage options, you can still use most third-party search tools to add a search function to your site. But Contemplate also includes a built-in search function designed specifically for its flat-file options. You can try it here:

 

Pre-render embedded files

Normally Contemplate will assemble all the pieces of your page, then run any included PHP code all at once. This means that code in your templates can interact with code in your content files as if they are one seamless file. But in some cases you might want your code to run before it is assembled into the page … or you might want to embed scripts from other languages besides PHP. You can use the PRE_RENDER_FILES option in config/constants.php to do this. For example, PRE_RENDER_FILES is set to "cgi" for this site, so you can click here to reload the page with an embedded Perl script.

Store content in HTML forms

If you want to access small pieces of content, such as an employee's birth date, and can't create a more complex database back-end and user interface, an alternative is to create an HTML form inside of a content field and enter data with an HTML editor. For example, we can extract the following data from the content/forms.html file:

George's full name: George Jones
Martin's status: full-time
Lucy's role: Instructional Designer