[TYPO3-templavoila] Different template for list and detail

Dmitry Dulepov dmitry at typo3.org
Tue Jan 20 08:48:29 CET 2009


Jan Bednarik wrote:
> I need different templates for tt_products list and detail view. I've
> got detail view on the same page as list view (because of the
> navigation), so I need to choose which template based on a condition (is
> tx_ttproducts_pi1[product] set).
> Is there any way how to achieve this?

There are two ways: one is pure TS, another is with an extension.

With TS you will need a condition in TS setup. It will be something like this:

[globalVar = GP:tx_ttproducts_pi1[product] = /^$/]
# empty
page.10.childTemplate = detail_view

Also you will need to use TSConfig to add "detail_view" as a new rendering type to the "Select a type of rendering" selector in the template object properties. I do not remember the exact TSConfig sntax but it is like with any TCEFORM TSConfig (not TV-specific). You can find details in the TSConfig reference on typo3.org.

When you added TSConfig, you need to make a subtemplate of the main template with "detail_view" as rendering type. Condition will force this subtemplate when you have a GET/POST var for tt_products.

If you prefer to code, you can use a hook named $TYPO3_CONF_VARS['EXTCONF']['templavoila']['pi1']['renderElementClass']['renderElement_preProcessRow']. It accepts database row, table name and a pointer to tx_templavoila_pi1 as a parameter. You can change the uid of a template object in the row. But this is too much I think, TS is easier.

Good luck! :)

Dmitry Dulepov
TYPO3 core team
"Sometimes they go bad. No one knows why" (Cameron, TSCC, "Dungeons&Dragons")

More information about the TYPO3-project-templavoila mailing list