Skip to content

Instantly share code, notes, and snippets.

@smichaelsen
Created November 2, 2012 14:02
Show Gist options
  • Save smichaelsen/4001529 to your computer and use it in GitHub Desktop.
Save smichaelsen/4001529 to your computer and use it in GitHub Desktop.
Typoscript Condition that checks field up in rootline
<?php
/**
* Usage example: [userFunc = levelFieldCondition(layout=1)]
*
* @param string $assumption
* @return bool
*/
function levelFieldCondition($assumption) {
list($fieldname, $value) = t3lib_div::trimExplode('=', $assumption);
foreach($GLOBALS['TSFE']->rootLine as $rootlinePage) {
if($rootlinePage[$fieldname] !== NULL) {
return $value == $rootlinePage[$fieldname];
}
}
return strtolower($value) === 'null';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment