【问题标题】:Adding <referenceBlock name="head.additional"> Magento 2 not working添加 <referenceBlock name="head.additional"> Magento 2 不工作
【发布时间】:2017-08-14 21:21:36
【问题描述】:

我在前端布局中有这些块:

    <referenceContainer name="content">
        <block class="Dfl\Marketplace\Block\Profile" name="marketplace_sellerprofile" template="profile.phtml" cacheable="false" before="-"/>
    </referenceContainer>
    <referenceContainer name="sidebar.main">
        <block class="Dfl\Marketplace\Block\Profile" name="marketplace_sellerprofileleft" template="profile_left_sidebar.phtml" cacheable="false" before="-"/>
    </referenceContainer>
    <referenceContainer name="sidebar.additional">
        <block class="Dfl\Marketplace\Block\Profile" name="marketplace_sellerprofileright" template="profile_right_sidebar.phtml" cacheable="false" before="-"/>
    </referenceContainer>

然后我想添加一个新块以便将其插入该部分。 我在这些块上方添加了以下命令

    <referenceBlock name="head.additional">
      <block class="Dfl\Marketplace\Block\Profile" name="marketplace_social_tags" template="social_tags.phtml" />
    </referenceBlock>

然后在我的 social_tags.phtml 模板中,我只是添加了一个简单的元条目。

meta entry example

然后我运行 setup:upgrade 和 setup:static-content:deploy en_US es_ES 但该条目不在 head 标签中。 我点击了这些链接,但无法显示元条目。

Atwix - Adding blocks to the head section in Magento 2

add-block-in-head-tag-in-magento-2

有什么帮助吗?缺少什么?

【问题讨论】:

    标签: magento magento2


    【解决方案1】:

    男人。在尝试将hreflang事物放在脑海中时,我遇到了同样的问题。 试了4个小时。

    即使几个站点甚至一个示例模块都引用了 default.xml 中的 head.additional - 我发现,对我来说它只在使用时才有效

    <referenceBlock name="head.additional">
    

    在 default_head_blocks.xml 中

    这让我很抓狂。

    【讨论】:

      猜你喜欢
      • 2016-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-15
      • 1970-01-01
      • 1970-01-01
      • 2019-01-14
      相关资源
      最近更新 更多