elgentos/magento2-alternate-urls

为网店所有页面添加替代URL(hreflang)

1.2.1 2023-05-23 06:44 UTC

This package is auto-updated.

Last update: 2024-09-23 11:11:37 UTC


README

允许配置并添加替代URL到每个页面的<head>部分。其他网站/商店的链接可以在管理界面手动创建

安装

此包可以使用Composer安装。

composer require elgentos/magento2-alternate-urls
bin/magento module:enable Elgentos_AlternateUrls
bin/magento setup:upgrade

使用方法

要使用此模块,您需要启用模块并添加一些映射来“连接”网站/商店。脚本将自动为当前页面找到的每个链接添加对<head>的引用。

扩展到其他页面类型

要将此功能扩展到其他页面类型(如模块中的博客文章),您需要创建一个自定义模块并添加一个实现Elgentos\AlternateUrls\Type\TypeInterface的自定义类型。之后,您需要将您的自定义类型添加到default.xmlalternate_urls块的typeInstances中。

示例

<?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="alternate_urls">
            <arguments>
                <argument name="typeInstances" xsi:type="array">
                    <item name="custom_page_type" xsi:type="object">
                        MyNamespace\CustomPageTypeAlternateUrls\Type\CustomPageType
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

贡献

欢迎提交拉取请求。对于重大更改,请首先提出问题以讨论您想要更改的内容。

请确保根据需要更新测试。

许可证

专有