If you give us more context for how this deprecated API method is used, we can suggest the proper code to replace it. Can you post the Snippet code in a gist or other pastebin application?
1)
the site homepage returns a nice, unstyled:
Fatal error: Call to undefined method modX::getTemplateVarOutput() in/www/vhosts/.../modx/core/cache/includes/elements/modsnippet/22.include.cache.php on line 8
I have a snippet with a ’$document_tvs=$modx->getTemplateVarOutput(true, $id);’ call (deprecated) how should I upgrade it exactly? (not clear from the http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1 page)
Did you make sure to clear your browser cache? It could be cached JS. Can you provide more information on what distribution, PHP version, etc. so we can provide better help?
2)
the manager acts weird, i.e. the Resources tree is empty (am I missing ’context’ somehow ?), Elements and Files are there.
Every other page loads and lists items correctly.
1)
the site homepage returns a nice, unstyled:
Fatal error: Call to undefined method modX::getTemplateVarOutput() in/www/vhosts/.../modx/core/cache/includes/elements/modsnippet/22.include.cache.php on line 8
I have a snippet with a ’$document_tvs=$modx->getTemplateVarOutput(true, $id);’ call (deprecated) how should I upgrade it exactly? (not clear from the http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1 page)
$resource = $modx->getObject('modResource', $id);
if($resource) {
$tvs = array();
foreach($resource->getMany('TemplateVars') as $templateVar) {
$tvs[$templateVar->get('name')] = $templateVar->renderOutput($resource->get('id'));
}
}
If you give us more context for how this deprecated API method is used, we can suggest the proper code to replace it. Can you post the Snippet code in a gist or other pastebin application?
$output = "";
$document_tvs=$modx->getTemplateVarOutput(true, $id);
$templatevar_output=$document_tvs['secondaryNav'];
if ($templatevar_output){
$params['parents']=$templatevar_output;
$params['tpl']="SideColumnNews";
$output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
}
unset($document_tvs, $templatevar_output, $params);
$modx->setPlaceholder('2ndNavUlLi', $output);
return $modx->getChunk('sideMenuChunk');
Did you make sure to clear your browser cache? It could be cached JS. Can you provide more information on what distribution, PHP version, etc. so we can provide better help?
<?php
$output = "";
/* use getObject() to get the modTemplateVar instance you want by name */
$secondaryNav = $modx->getObject('modTemplateVar', array('name' => 'secondaryNav'));
if ($secondaryNav) {
/* use renderOutput() to get the processed value for the Resource with $id */
$tvOutput = $secondaryNav->renderOutput($id);
if (!empty($tvOutput)) {
$params = array(
'parents' => (integer) $tvOutput,
'tpl' => "SideColumnNews"
);
$output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
}
}
/* pass properties to the chunk to limit placeholder scope to that chunk */
return $modx->getChunk('sideMenuChunk', array('2ndNavUlLi' => $output));
<?php
$output = "";
/* use new getElement() method from the parser */
$secondaryNav = $modx->parser->getElement('modTemplateVar', 'secondaryNav');
if ($secondaryNav) {
$tvOutput = $secondaryNav->renderOutput($id);
if (!empty($tvOutput)) {
$params = array(
'parents' => (integer) $tvOutput,
'tpl' => "SideColumnNews"
);
$output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
}
}
return $modx->getChunk('sideMenuChunk', array('2ndNavUlLi' => $output));
In 2.1, you can further enhance performance by using the new modParser->getElement() method that takes advantage of the new modX->sourceCache; this will reduce database access with uncached Elements vs. using getObject()...
<?php $output = ""; /* use new getElement() method from the parser */ $secondaryNav = $modx->parser->getElement('modTemplateVar', 'secondaryNav'); if ($secondaryNav) { $tvOutput = $secondaryNav->renderOutput($id); if (!empty($tvOutput)) { $params = array( 'parents' => (integer) $tvOutput, 'tpl' => "SideColumnNews" ); $output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>'; } } return $modx->getChunk('sideMenuChunk', array('2ndNavUlLi' => $output));