带有简单消息的自定义构建模块未显示在 magento 2.4.1 中的单个产品详细信息页面上?
Custom built module with simple message is not displaying on single product detail page in magento 2.4.1?
所以我创建了一个模块来在单个产品页面上显示“hello world”消息,如下所示:
但是“Hello world”消息未显示在产品页面上。
我的自定义模块如下所示:
registration.php 文件如下所示:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE, //type
'Paymentblock_Ext', //componentName
__DIR__ //path
);
?>
module.xml 文件如下所示:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Paymentblock_Ext" setup_version="1.0.0">
</module>
</config>
catalog_product_view.xml 文件如下所示:
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Paymentblock\Ext\Block\PaymentMethod" name="custompaymentblock" template="Paymentblock_Ext::custom_ptype.phtml"/>
</referenceContainer>
</body>
custom_ptype.phtml 文件如下所示:
<h3>Hello World</h3>
PaymentMethod.php 文件如下所示:
<?php
namespace Paymentblock\Ext\Block;
use Magento\Framework\View\Element\Template;
class PaymentMethod extends Template {
}
?>
我已应用以下命令在产品页面上查看模块效果:
php magento setup:di:compile
我的模块在启用模块列表中,我可以通过应用以下命令在此处看到:
php bin/magento module:status
但是,我仍然无法在单个产品页面上看到“Hello World”消息。
谁能指出我这里做错了什么????
运行 设置升级以设置模块:php bin/magento setup:upgrade
主题布局更新文件“/var/www/html/app/code/Paymentblock/Ext/view/frontend/layout/catalog_product_view.xml”无效。标记页第 2 行中数据的过早结束行:8
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Paymentblock\Ext\Block\PaymentMethod" name="custompaymentblock" template="Paymentblock_Ext::custom_ptype.phtml"/>
</referenceContainer>
</body>
</page>
添加</page>
所以我创建了一个模块来在单个产品页面上显示“hello world”消息,如下所示:
但是“Hello world”消息未显示在产品页面上。
我的自定义模块如下所示:
registration.php 文件如下所示:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE, //type
'Paymentblock_Ext', //componentName
__DIR__ //path
);
?>
module.xml 文件如下所示:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Paymentblock_Ext" setup_version="1.0.0">
</module>
</config>
catalog_product_view.xml 文件如下所示:
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Paymentblock\Ext\Block\PaymentMethod" name="custompaymentblock" template="Paymentblock_Ext::custom_ptype.phtml"/>
</referenceContainer>
</body>
custom_ptype.phtml 文件如下所示:
<h3>Hello World</h3>
PaymentMethod.php 文件如下所示:
<?php
namespace Paymentblock\Ext\Block;
use Magento\Framework\View\Element\Template;
class PaymentMethod extends Template {
}
?>
我已应用以下命令在产品页面上查看模块效果:
php magento setup:di:compile
我的模块在启用模块列表中,我可以通过应用以下命令在此处看到:
php bin/magento module:status
但是,我仍然无法在单个产品页面上看到“Hello World”消息。
谁能指出我这里做错了什么????
运行 设置升级以设置模块:php bin/magento setup:upgrade
主题布局更新文件“/var/www/html/app/code/Paymentblock/Ext/view/frontend/layout/catalog_product_view.xml”无效。标记页第 2 行中数据的过早结束行:8
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Paymentblock\Ext\Block\PaymentMethod" name="custompaymentblock" template="Paymentblock_Ext::custom_ptype.phtml"/>
</referenceContainer>
</body>
</page>
添加</page>