7.2. Opt_View class
7.2.23. inherit()
7.2.22. hasDynamicContent()
« Previous
7.2.24. remove()
Next »

7.2.23. inherit()

ConstructMethod
Visibilitypublic
Referencevoid inherit( string $sourceFile [, string $destinationFile ] )

Performs a dynamic inheritance on the templates associated to the current view. The method may be called in two ways:

$view->inherit('inherited_by.tpl');

In this case, the template associated to the view is inherited by inherited_by.tpl. Alternatively, we may do the following:

$view->inherit('inheriting_template.tpl', 'inherited_by.tpl');

Now we inherit the inheriting_template.tpl with inherited_by.tpl. This allows to create compound inheritance chains:

$view = new Opt_View('template1.tpl');
$view->inherit('template2.tpl');
$view->inherit('template2.tpl', 'template3.tpl');
$view->inherit('template3.tpl', 'template4.tpl');

In order to make the dynamic inheritance possible, the templates must allow it:

<opt:extend file="default_file.tpl" dynamic="yes">
 
    <!-- some code snippets -->
 
</opt:extend>

Another way to create the dynamic inheritance is to use branches. See the chapter about inheritance to get to know more.

Extending snippets

In OPT, the templates are not limited to extend whole templates. It is possible to extend one of existing snippets created with opt:snippet instruction. In order to get to know more about extending snippets, see a chapter about template inheritance.

7.2.23. inherit()
7.2. Opt_View class
« Previous
7.2.22. hasDynamicContent()
Next »
7.2.24. remove()