TSRef - TypoScript Reference
1.7.27.
1.7.28. TEMPLATE
Property: | Data type: | Description: | Default: |
|---|---|---|---|
template | cObject | This must be loaded with the template-code. If not the object returns nothing. |
|
subparts | Array... of cObject | This is an array of subpart-markers (case-sensitive). A subpart is defined by two markers in the template. The markers must be wrapped by "###" on both sides. You may insert the subpart-markers inside HTML-comment-tags!!
Example: subparts { HELLO = TEXT HELLO.value = En subpart er blevet erstattet!! }
In the templates: <!-- start of subpart: ###HELLO### --> This is the HTML.code, that will be loaded in the register and replaced with the result... <!-- end ###HELLO### -->
NOTE: Before the content-objects of each subpart is generated, all subparts in the array are extracted and loaded into the register so that you can load them from there later on. The register-key for each subparts code is "SUBPART_[theSubpartkey]". In addition the current-value is loaded with the content of each subpart just before the cObject for the subpart is parsed. That makes it quite easy to load the subpart of the cObject (eg: ".current=1") Eg. this subpart above has the register-key "SUBPART_HELLO". This is valid ONLY if the property .nonCachedSubst is not set! (see below) |
|
relPathPrefix | string / properties | Finds all relative references (eg. to images or stylesheets) and prefixes this value. If you specify properties (uppercase) these will match HTML tags and specify alternative paths for them. See example below. If the property is named "style" it will set alternative path for the "url()" wrapper that may be in <style> sections.
Example: page.10 = TEMPLATE relPathPrefix.IMG = fileadmin/img/ Inthis example all relative paths found are prefixed "fileadmin/" unless it was the src attribute of an img tag in which case the path prefixed is "fileadmin/img/" |
|
marks | Array... of cObject | This is an array of marks-markers (case-sensitive). A mark is defined by one markers in the template. The marker must be wrapped by "###" on both sides. Opposite to subparts, you may NOT insert the subpart-markers inside HTML-comment-tags! (They will not be removed). Marks are substituted bya str_replace-function. The subparts loaded in the register is available also to the cObjects of markers (only if .nonCachedSubst is not set!). |
|
wraps | Array... of cObject | This is an array of wraps-markers (case-sensitive). This is shown best by an example: Example: wraps { MYLINK = TEXT MYLINK.value = <A href="#"> | </A> }
In the template: This is <!--###MYLINK###-->a link to my<!--###MYLINK###--> page!
In this example the MYLINK subpart will be substituted by the wrap which is the content returned by the MYLINK cObject. |
|
workOnSubpart | string | This is an optional definition of a subpart, that we decide to work on. In other words; if you define this value that subpart is extracted from the template and is the basis for this whole templateobject. |
|
markerWrap | wrap | This is the wrap the markers is wrapped with. The default value is ### | ### resulting in the markers to be presented as ###[marker_key]###. Any whitespace around the wrap-items is stripped before they are set around the marker_key. | ### | ### |
substMarksSeparately | boolean | If set, then marks are substituted in the content AFTER the substitution of subparts and wraps. Normally marks are not substituted inside of subparts and wraps when you are using the default cached mode of the TEMPLATE cObject. That is a problem if you have marks inside of subparts! But setting this flag will make the marker-substitution a non-cached, subsequent process. Another solution is to turn of caching, see below. |
|
nonCachedSubst | boolean | If set, then the substitution mode of this cObject is totally different. Normally the raw template is read and divided into the sections denoted by the marks, subparts and wraps keys. The good thing is high speed, because this "pre-parsed" template is cached. The bad thing is that templates that depends on incremental substition (where the order of substition is important) will not work so well. By setting this flag, markers are first substituted by str_replace in the template - one by one. Then the subparts are substituted one by one. And finally the wraps one by one. Obviously you loose the ability to refer to other parts in the template with the register-keys as described above. |
|
[tsref:(cObject).TEMPLATE]
Example:
page.10 = TEMPLATE
page.10 {
template = FILE
template.file = fileadmin/test.tmpl
subparts {
HELLO = TEXT
HELLO.value = This is the replaced subpart-code
}
marks {
Testmark = TEXT
Testmark.value = This is replacing a simple marker in the HTML-code
}
workOnSubpart = DOCUMENT
}
In this example a template named test.tmpl is loaded.