只应通过Magento问题引用传递变量

时间:2010-12-15 10:52:44

标签: php debugging magento

为了在生成的html源代码中查看模板的路径以进行调试,我在

中使用了以下代码片段

应用程序/代码/核心/法师/核心/砌块/的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;
}

但现在在错误日志中我看到以下内容: 2010-12-13T21:55:35 + 00:00 ERR(3):严格注意:只有变量才能在第245行的/app/code/core/Mage/Core/Block/Template.php中通过引用传递

如何引用它以避免此错误?

2 个答案:

答案 0 :(得分:1)

改为安装开发人员工具栏扩展程序。或者从管理员打开模板提示。

答案 1 :(得分:1)

非常确定你的问题就在这一行

$tagName = 'template_'.current(explode('.',end(explode('/',$template))));

endcurrent方法接受一个数组变量作为参数,通过引用传递。你传递的函数调用的结果,PHP不喜欢。假设代码片段试图获得无扩展名模板名称,请尝试使用

$parts  = pathinfo($template);
$tagName    = $parts['filename']; 
相关问题