[TYPO3-ect] Improvement of the template engine
Ernesto Baschny [cron IT]
ernst at cron-it.de
Thu Jan 26 11:01:31 CET 2006
JoH schrieb am 26.01.2006 00:36:
>>the classical template maker looks like this: ###PROJECT_ABSTRACT### .
>>
>>"<h3>###PROJECT_ABSTRACT###<h3>"
>>If the project name is empty the resulting output is "<h3></h3>".
>>
>> (...)
>>
>>What do you propose the best direction to go with templating features?
>>
>>A) Extending the ### System?
>>B) Develope of an XML variant?
>>C) Implementing smarty or a simlar tool more officialy?
>>D) Other idea
>>E) Doing nothing
> D)
> Don't use markers to replace the content inside a tag.
> Use wraps instead and markers without a tag.
>
> HTML-Template
>
> ###MARKER1###
> ###MARKER2###
>
> TS-Template
I would suggest: extension developers shouldn't use html-templates at
all. It should be up to the site implementator if he wants to use pure
TypoScript, html-templates or other methods for rendering plugins
output. You just need to provide a consistent and documented set of
cObjects and stdWraps so that one can do whatever he wants with the data
your plugin provides (which would mean a real separation of data
generation and data rendering):
PHP-Code (something like this...):
function singleView() {
$row = getMyDataRow();
$this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
$this->local_cObj->start($row, 'my_data_table');
$content = $this->local_cObj->cObjGetSingle($conf['detailView'],
$conf['detailView.']);
return $content;
}
TS-Code with pure TypoScript templating:
plugin.my_plugin {
detailView = COA
detailView {
10 = TEXT
10 {
field = title
wrap = <h3>|</h3>
required = 1
}
20 = TEXT
20 {
field = bodytext
wrap = <p>|</p>
required = 1
}
}
}
TS-Code with the given HTML-template (marks/subparts):
plugin.my_plugin {
detailView = TEMPLATE
detailView {
workOnSubpart = SINGLE
template = FILE
template.file = EXT:my_ext/res/template.html
marks.MARKER1 = TEXT
marks.MARKER1 {
field = title
wrap = <h3>|</h3>
required = 1
}
marks.MARKER2 = TEXT
marks.MARKER2 {
field = bodytext
wrap = <p>|</p>
required = 1
}
}
}
The idea of this is to be able to get rid of all "html-templates" as
files in the fileadmin area, which are a pain for me to manage (no
versioning, etc), which is why I would love to be able to have
everything in database.
We could even use this scheme in existing extensions like tt_news and
still maintain backwards compatibility: The defaults provided in
plugin.tt_news should just use the existing html-templates, but this
should be done in TypoScript instead of in PHP, so one can swap to a
different templating scheme at will.
Cheers,
Ernesto
More information about the TYPO3-team-extension-coordination
mailing list