首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >只应通过Magento问题中的引用传递变量

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

Stack Overflow用户
提问于 2010-12-15 18:52:44
回答 2查看 1.7K关注 0票数 2

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

app/code/core/Mage/Core/Block/Template.php

代码语言:javascript
运行
复制
/**
 * 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中的引用传递

为了避免这个错误,应该如何引用它?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-12-15 23:05:40

我很确定你的问题是这一行

代码语言:javascript
运行
复制
$tagName = 'template_'.current(explode('.',end(explode('/',$template))));

endcurrent方法接受数组变量作为参数,通过引用传递。您正在传递函数调用的结果,这是PHP不喜欢的。假设snippet正在尝试获取一个无扩展名的模板名称,请尝试执行以下操作

代码语言:javascript
运行
复制
$parts  = pathinfo($template);
$tagName    = $parts['filename']; 
票数 1
EN

Stack Overflow用户

发布于 2010-12-15 19:16:09

改为安装Developer Toolbar扩展。或者从Admin打开模板提示。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4449102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档