【问题标题】:custom head block is not fetching page title and meta data自定义头块未获取页面标题和元数据
【发布时间】:2013-05-08 09:48:32
【问题描述】:

我在我的 Magento 商店中构建了一个自定义的“head”块,其中仅包含我在整个站点中使用的必要脚本和文件。为了这个问题,我们称它为“new_head”。仅当用户在系统页面上时;结帐,登录/登录,我的帐户等...,是否使用了本机“头”块。

到目前为止,这非常有效,但我现在的问题是页面标题和元数据在每个页面上都显示默认值 - “Magento Enterprise Edition”

显然这不好。所有原始的“echo”语句都在我的“head.phtml”文件中:

<title><?php echo $this->getTitle() ?></title>
<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
<meta name="keywords" content="<?php echo htmlspecialchars($this->getKeywords()) ?>" />
<meta name="robots" content="<?php echo htmlspecialchars($this->getRobots()) ?>" />

我知道问题的原因,这是因为我没有在我的模板中调用本机“head”块引用,并且我怀疑在布局或核心文件的某个地方有对“head”的引用获取上述值。

所以我的问题是:我可以在 Magento 的哪个位置设置上述值以同时指向本机“head”块引用和我的自定义“new_head”块引用?

【问题讨论】:

  • 所以你的块 phtml 有原始的 head.php 块作为代码,还是你也使用自定义块(php)?
  • 我没有用自定义的head.php,还是一样的,我没改过。
  • 我应该使用自定义的 head.php 吗?
  • 不,我只是想确定 getTitle() 函数返回的是正常的 magento 标题,而不是一些自定义标题。您是否通过您的 phtml 更改了布局文件中的默认头部,或者您是否更改了块的名称或其他内容?
  • 在我正在使用的 .phtml 中:getChildHtml('new_head')?>

标签: magento block title meta head


【解决方案1】:

问题解决了。不要使用自定义头部。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 2016-09-18
    • 2020-12-28
    • 1970-01-01
    • 2014-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多