【问题标题】:Magento 2 CMS Page 'Layout Update XML' option add xml code to get custom meta tagMagento 2 CMS 页面“布局更新 XML”选项添加 xml 代码以获取自定义元标记
【发布时间】:2018-06-25 02:34:36
【问题描述】:

我知道如何使用“布局更新 XML”选项在 Magento 1 CMS 页面中添加自定义元标记。

<reference name="head">
    <block type="core/text" name="custommeta">
        <action method="setText">
            <text>
                <![CDATA[<meta data-customid="customid_meta_1" />]]>
            </text>
        </action>
    </block>
</reference>

如何使用选项“布局更新 XML”以相同的方式为 Magento 2 中的特定 CMS 页面添加元标记

<meta data-customid="customid_meta_1" />

【问题讨论】:

    标签: xml magento2 magento2.1


    【解决方案1】:

    我认为以下应该适合你

    <head>
        <meta name="data-customid" content="customid_meta_1"/>
    </head>
    

    您可能会看到 vendor\magento\module-theme\view\frontend\layout\default_head_blocks.xml 文件以供参考。

    可以在以下文件中找到相同元的 Magento1 代码 app\design\frontend\rwd\default\layout\page.xml

    <!-- Sets viewport meta tag using text block -->
    <block type="core/text" name="head.viewport">
          <action method="setText"><text><![CDATA[<meta name="viewport" content="initial-scale=1.0, width=device-width" />]]>&#10;</text></action>
    </block>
    

    同时检查以下文件 vendor\magento\framework\View\Page\Config\Renderer.php 中的 getMetadataTemplate 方法

    更新:检查CMS Page with in layout update xml

    【讨论】:

    • 感谢@muk,但我不想添加带有“名称”和“内容”的普通元标记。我需要添加这个元标记 -
    猜你喜欢
    • 1970-01-01
    • 2012-09-11
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-29
    • 1970-01-01
    相关资源
    最近更新 更多