hypershop/module-shortcodes

Magento 2模块,用于向CMS页面和块添加短代码,并将其转换为HTML包装。

100.4.5 2022-11-02 08:35 UTC

This package is auto-updated.

Last update: 2024-09-04 12:44:25 UTC


README

目标

  • 本模块旨在向CMS页面和块添加短代码,并将其转换为HTML包装。

安装/设置

  • 使用命令composer require hypershop/module-shortcodes安装模块
  • 安装后,运行bin/magento setup:upgrade将其添加到Magento模块列表中。

使用/设置

最初,此模块唯一的短代码是

[wrap]
Your content here
[/wrap]

这将转换为

<div class="wrap">
Your content here
</div>

还可以向短代码添加额外的类

[wrap extra-class="extra-class-one extra-class-two extra-class-three"]
Your content here
[/wrap]

这将转换为

<div class="wrap extra-class-one extra-class-two extra-class-three">
Your content here
</div>

您可以通过在布局XML文件中扩展以下方式,在主题或自定义模块或主题中扩展短代码列表

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="shortcodes">
            <arguments>
                <argument name="list" xsi:type="array">
                    <item name="second-shortcode" xsi:type="array">
                        <item name="shortcode" xsi:type="string">second-shortcode</item>
                        <item name="class" xsi:type="string">second-shortcode-class</item>
                    </item>
                    <item name="third-shortcode" xsi:type="array">
                        <item name="shortcode" xsi:type="string">third-shortcode</item>
                        <item name="class" xsi:type="string">third-shortcode-class</item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

常见问题

  • 目前尚未发现。