Functions:include

Include allows you to insert other templates into the current template.

include(string $file [, int $cache_time = null [, string $cache_id = null [, string $compile_id = null [, mixed $data = '_root' [, string $assign = null [, array $rest = array ]]]]]] )


 * file : the resource name to include
 * cache_time : the template cache length in seconds, defaults to null (= will take the Dwoo object cache length)
 * cache_id : the template cache id
 * compile_id : the template compile id
 * data : this is the data array that will be used as the root data for the included template, by default the current data is sent
 * assign : if set, the included file will be assigned to the given variable and it will not be output
 * rest : any number of values that will override the $data argument (see below)

As an example, you may have a common header that you would like to include into all of your pages. This can be accomplished like this :

index.html: header.html:

Output:

Overriding/passing template variables
Sometimes you may need to pass variables to another template without wanting to include them in the data parameter of the get or output methods of the Dwoo class. This can be done by adding them in as parameters as the following example illustrates:

site_header.tpl:

page_about.tpl:

In the above example we have two files, one for a header and a snippet of a fictional 'About us' page. The page_about.tpl is parsed and passes it's title "About Us" through the title variable in the include statement to give the output:

Output: