background-image: url({{imagebas}});
[[GetField?field=`imagebas`]]
@import url('/css/styles.css?docid=[*id*]');
Fatal error: Call to undefined function: gettv() in /var/www/virtual/mydomain.com/htdocs/manager/includes/document.parser.class.inc.php(748) : eval()’d code on line 211Si par contre dans mon chunk je remplace `imagebas` par `pagetitle` par exemple, la feuille de styles s’affiche correctement, avec de surcroît le nom de la page au bon endroit
$id = (isset($docid)) ? $docid : $modx->documentIdentifier;
/* ================================================== GetField ================================================== Gets a field or template variable for current or specified document or its parent up to specified number of levels until ultimate parent is reached. Author: Grzegorz Adamiak [grad] Version: 1.2.2 @2006-10-25 08:54:45 License: LGPL MODx: 0.9.2.1 Uses idea of getDoc by Mark with modification from luke.stokes History: # 1.2.2 - a quick fix to "Cannot redeclare function" # 1.2.1 - reworked fetching of template variable (again ;) to enable output of widget # 1.2 - reworked fetching of template variable value to get INHERITED value - removed defaulting to 'pagetitle' when $field not found; this is due to fact that tv can have empty value # 1.1.1 - fixed small bug with $parentLevel and $topid check; now should work as expected # 1.1 - reworked fetching of template variable value, now it gets computed value instead of nominal; however, still not the inherited value - changed license to LGPL # 1.0 - first public release -------------------------------------------------- */ /* Parameters ----------------------------------------------- */ # functions # --------------------------------------------- # gets (inherited) value of template variable if (!function_exists(getTV)) { function getTV($modx,$docid,$doctv) { /* apparently in 0.9.2.1 the getTemplateVarOutput function doesn't work as expected and doesn't return INHERITED value; this is probably to be fixed for next release; see http://modxcms.com/bugs/task/464 $output = $modx->getTemplateVarOutput($tv,$docid); return $output[$tv]; */ while ($pid = $modx->getDocument($docid,'parent')) { $tv = $modx->getTemplateVar($doctv,'*',$docid); if (($tv['value'] && substr($tv['value'],0,8) != '@INHERIT') or !$tv['value']) // tv default value is overriden (including empty) { //$output = $tv['value']; $output = $modx->getTemplateVarOutput($doctv,$docid); $output = $output[$doctv]; break; } else // there is no parent with default value overriden { $output = trim(substr($tv['value'],8)); } $docid = $pid['parent']; // move up one document in document tree } // end while return $output; } } # $docid [ int ] # Document for which to get a field. # Default: current document $id = (isset($_GET['docid'])) ? $_GET['docid'] : (isset($docid)) ? $docid : $modx->documentIdentifier; # $field [ string ] # Field to get for the document: # - any of the document object fields # (http://modxcms.com/the-document-object.html) # - template variable assigned to the document # Default: 'pagetitle' $field = (isset($field)) ? trim($field) : 'pagetitle'; # $parent [ 0 | 1 ] # $parent = 1 - returns the field for the parent # of the document. # Default: 0 $parent = (isset($parent)) ? $parent : 0; # $parentLevel [ int ] # How high in the document tree to search for the # parent of the document? # - $parentLevel = 0 - returns the ultimate parent # (right under site root) # - $parentLevel = 1 - returns the direct parent # Default: 0 $parentLevel = (isset($parentLevel) && is_int((int) $parentLevel)) ? $parentLevel : 0; # $topid [ int ] # Id of the topmost document in the document tree # under which to search for a parent. # Default: 0 $topid = (isset($topid) && is_int((int) $topid)) ? $topid : 0; /* End parameters ----------------------------------------------- */ # search for parent document id # --------------------------------------------- if ($parent) { # build an array of document's ancestors $arrDocParents[] = $id; // add current document on first place # get all parents back to root of document tree while (($pid = $modx->getDocument($id,'parent')) && ($pid['parent'] != 0)) { $id = $pid['parent']; // move up one document in document tree $arrDocParents[] = $id; // add parent to array of document's ancestors } // end while $countParents = count($arrDocParents); # determine the parent id switch ($topid) { case 0: // not set or set to root of document tree ($parentLevel && ($parentLevel < $countParents)) ? ($docid = $arrDocParents[$parentLevel]) : // find parent in specified levels up ($docid = $arrDocParents[$countParents - 1]); break; default: // set to any other document $key = array_search($topid, $arrDocParents); // find the index of parent switch ($key) { case 0: // not an ancestor or the document itself $docid = 0; break; default: // parent is above the document in document tree ($parentLevel && ($parentLevel < $key)) ? ($docid = $arrDocParents[$parentLevel]) : // find parent in specified levels up ($docid = $arrDocParents[$key - 1]); } // end switch } // end switch } // end if else { $docid = $id; } // end else # get field or template variable for document # --------------------------------------------- // check for document field $docFields = $modx->getDocument($docid); $output = $docFields[$field]; // check for template variable if (!$output) { $output = getTV($modx,$docid,$field); } return $output;