## Apache Zeta Components Manual :: Docs For Class ezcTemplateLocation

### Template::ezcTemplateLocation

### Interface ezcTemplateLocation

Interface for classes implementing a dynamic template location.

An object implementing the ezcTemplateLocationInterface can be used as a substitute for the template source in the ezcTemplate::process() method and inside the template {include} block.

Inside a template, a custom function is used to create this location object. The following template source:

1. Hello word!
2. {includedynloc("my_template.ezt")}

With the following custom function definition:

1. classDynLocCFimplementsezcTemplateCustomFunction
2. {
3. publicstaticfunctiongetCustomFunctionDefinition($name)
4. {
5. if($name==="dynloc")
6. {
7. $def=new ezcTemplateCustomFunctionDefinition ();
8. $def->class= __CLASS__;
9. $def->method="dynloc";
10. $def->sendTemplateObject=true;
11. return$def;
12. }
13. returnfalse;
14. }
16. publicstaticfunctiondynloc($templateObj,$name)
17. {
18. returnnewDynamicLocation($templateObj,$name);
19. }
20. }

The dynloc() method returns a new DynamicLocation object. A simple implementation of the ezcTemplateLocationInterface is shown below:

1. classDynamicLocationimplementsezcTemplateLocationInterface
2. {
3. protected$templatePath;
4. protected$templateName;
6. publicfunction__construct($templateObj,$templateName)
7. {
8. $this->templateName=$templateName;
9. $this->templatePath=$templateObj->usedConfiguration->templatePath;
10. }
12. publicfunctiongetPath()
13. {
14. $loc=$this->templatePath."/".$this->templateName;
15. if(! file_exists ($loc) )
16. {
17. $loc="/fallback/".$this->templateName;
18. }
20. return$loc;
21. }
22. }

The template will first try to use the original template. If that template does not exist, it uses the fallback template.

Source for this file: /Template/src/interfaces/location.php

Version: | //autogen//

### Method Summary

public string | `getPath( )` Implement this method to return the path to the template source.

### Methods

#### getPath

string getPath( )

Implement this method to return the path to the template source.

The original template name is set with any other method.

Documentation generated by phpDocumentor 1.4.3