[TYPO3-english] Including typoscript templates through setup field?`
Peter Russ
peter.russ at 4many.net
Mon Feb 23 16:50:42 CET 2009
--- Original Nachricht ---
Absender: Stig Nørgaard Færch
Datum: 23.02.2009 11:59:
> I know conditions.
> But I don't think that this is what I'm looking for - unless I
> misunderstood something.
> How can I include typoscript templates conditionally with these conditions?
>
> /Stig
>
> Daniel Huf skrev:
>> Try here:
>> http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/4/1/
>>
>>
>> Daniel
>>
>> Stig Nørgaard Færch wrote:
>>> I know it's possible to include typoscript from typoscript setup
>>> through <INCLUDE_TYPOSCRIPT:somefile>.
>>>
>>> What I'm looking for is the possibility to include typoscript
>>> templates (sys_template) conditionally.
>>>
>>> Let's say that some constant is set to 1, then I want template A to
>>> be included.
>>> If the constant is set to 2, then I want tempalte B to be included.
>>>
>>> Is this somehow possible?
>>>
>>> /Stig
Can be done with userMatch condition:
Example to check if a template is set (s. fdfx_yaml)
<code>
function tx_fdfxyaml_userMatch($template)
{
$ok=false;
if (is_object($GLOBALS['TSFE']))
{
if (isset($GLOBALS['TSFE']->register['tx_rlmptmplselector_ca_tmpl']))
{
$ok=$GLOBALS['TSFE']->register['tx_rlmptmplselector_ca_tmpl']==$template;
} else {
if ($GLOBALS['TSFE']->page['tx_rlmptmplselector_ca_tmpl']!='0')
{
$GLOBALS['TSFE']->register['tx_rlmptmplselector_ca_tmpl'] =
$GLOBALS['TSFE']->page['tx_rlmptmplselector_ca_tmpl'];
$ok=$GLOBALS['TSFE']->register['tx_rlmptmplselector_ca_tmpl']==$template;
} else {
$confArray =
unserialize($GLOBALS["TYPO3_CONF_VARS"]["EXT"]["extConf"]["rlmp_tmplselector"]);
$tmplConf =
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_rlmptmplselector_pi1."];
if (is_null($tmplConf))
{
// this will be null if condition is used in constants
// TODO: is there any way to work around?
$tmplConf=array('inheritMainTemplates' => 1,'inheritSubTemplates'=>1);
}
if (is_array($tmplConf))
{
$rootLine = $GLOBALS['TSFE']->rootLine;
$pageSelect = t3lib_div::makeInstance('t3lib_pageSelect');
if (is_array ($rootLine))
{
if (intval($tmplConf['inheritMainTemplates']) == 1) {
foreach ($rootLine as $rootLinePage) {
$page = $pageSelect->getPage ($rootLinePage['uid']);
if ($page['tx_rlmptmplselector_main_tmpl']) {
$GLOBALS['TSFE']->register['tx_rlmptmplselector_main_tmpl'] =
$page['tx_rlmptmplselector_main_tmpl'];
break;
}
}
}
if (intval($tmplConf['inheritSubTemplates']) == 1)
{
foreach ($rootLine as $rootLinePage) {
$page = $pageSelect->getPage ($rootLinePage['uid']);
if ($page['tx_rlmptmplselector_ca_tmpl'])
{
$GLOBALS['TSFE']->register['tx_rlmptmplselector_ca_tmpl'] =
$page['tx_rlmptmplselector_ca_tmpl'];
$ok=$GLOBALS['TSFE']->register['tx_rlmptmplselector_ca_tmpl']==$template;
break;
}
}
}
}
}
}
}
}
return $ok;
}
</code>
include e.g. in localconf.php of your extension
and then to check:
[userFunc = tx_fdfxyaml_userMatch(h-123-f.html)]
<INCLUDE_TYPOSCRIPT:
source="FILE:EXT:fdfx_yaml/templates/typoscript/setup.h-123-f.txt">
<INCLUDE_TYPOSCRIPT:
source="FILE:EXT:fdfx_yaml/templates/typoscript/local/setup.h-123-f.txt">
[end]
Hopes that helps.
Peter.
--
Fiat lux!
Docendo discimus.
http://www.gidf.de
_____________________________
4Many� Services
uon GbR
XING: http://www.xing.com/profile/Peter_Russ
https://www.xing.com/go/invita/360052
http://www.xing.com/go/privatemessage/Peter_Russ
More information about the TYPO3-english
mailing list