| 13 | | Complex variable modifiers (objects) will be described soon. |
|---|
| | 14 | |
|---|
| | 15 | 2.b) You may create custom modifiers. To do this, create a new file in |
|---|
| | 16 | |
|---|
| | 17 | PATTEMPLATE_ROOT/patTemplate/Modifier |
|---|
| | 18 | |
|---|
| | 19 | or any of its sub-folders. In this file, you have to create a new class |
|---|
| | 20 | that's called |
|---|
| | 21 | |
|---|
| | 22 | patTemplate_Modifier_FILENAME |
|---|
| | 23 | |
|---|
| | 24 | where FILENAME is the name of your file (and thus also of your modifier). |
|---|
| | 25 | If your modifier is located in a subfolder, you have to include the folder |
|---|
| | 26 | name in the class name, e.g. patTemplate_Modifier_Html_Image. |
|---|
| | 27 | |
|---|
| | 28 | Your class should inherit from patTemplate_Modifier and provide the following |
|---|
| | 29 | method: |
|---|
| | 30 | |
|---|
| | 31 | string modify( string value, array params ) |
|---|
| | 32 | |
|---|
| | 33 | In the method you may modify the value and return it to the templating enginge. |
|---|
| 75 | | Custom template tags are not supported, yet. |
|---|
| | 95 | Custom Tags allow you to extend patTemplate. You may define classes that |
|---|
| | 96 | are instantiated and evaluated,, when patTemplate finds a tag that is not |
|---|
| | 97 | supported by the engine. Custom functions are evaluated by the template reader. |
|---|
| | 98 | To create your own template function, create a new class that inherits from |
|---|
| | 99 | patTemplate_Function and place it into |
|---|
| | 100 | |
|---|
| | 101 | PATTEMPLATE_ROOT/patTemplate/Function |
|---|
| | 102 | |
|---|
| | 103 | In this class you have to implement on function: |
|---|
| | 104 | |
|---|
| | 105 | string call( array params, string content ) |
|---|
| | 106 | |
|---|
| | 107 | This method will be called on the closing tag with the same name as |
|---|
| | 108 | your file (and class). patTemplate_Reader will pass the attributes |
|---|
| | 109 | and the content of the tag to your method. You will then have to |
|---|
| | 110 | compute the data you want to insert to the template and return the |
|---|
| | 111 | string. This will be inserted instead of your custom tag. |
|---|
| | 112 | |
|---|
| | 113 | Custom Template Functions allow to do things like: |
|---|
| | 114 | - Modify parts of the template while reading it |
|---|
| | 115 | - Insert the current date/time |
|---|
| | 116 | - Get request variables and insert them into the template |
|---|
| | 117 | - ... |
|---|
| | 118 | |
|---|
| | 119 | Custom template functions (or tags) can also be called Horst. If you want to |
|---|
| | 120 | know, why they are called Horst, you could contact gERD or Argh. |
|---|