Only variable should be passed by referenced in Magento problem
In order to see the path to template in generated html source code for debuggin purposes I used the following code snippet in the
app/code/core/Mage/Core/Block/Template.php
/**
* Render block
*
* @return string
*/
public function renderView()
{
$this->setScriptPath(Mage::getBaseDir('design'));
$showDebug = true;
if (!$showDebug) {
$html = $this->fetchView($this->getTemplateFile());
}
else {
$template = $this->getTemplateFile();
$tagName = 'template_'.current(explode('.',end(explode('/',$template))));
$html = '<'.$tagName.'><!-- '.$template.' -->';
$html .= $this->fetchView($template);
$html .= '<!--/ '.$template.' --></'.$tagName.'>';
}
return $html;
}
but now in the error logs I see the following: 2010-12-13T21:55:35+00:00 ERR (3): Strict Notice: Onl开发者_JS百科y variables should be passed by reference in /app/code/core/Mage/Core/Block/Template.php on line 245
How should this be referenced in order to avoid this error?
Pretty sure your problem is this line
$tagName = 'template_'.current(explode('.',end(explode('/',$template))));
The end and current methods accept an array variable as a paramater, passed by reference. You're passing the result of a function call, which PHP doesn't like. Assuming that snippet is trying to get an extension-less template name, try this instead
$parts = pathinfo($template);
$tagName = $parts['filename'];
Install the Developer Toolbar extension instead. Or turn on Template Hints from the Admin.
精彩评论