douyan1613 2016-10-19 07:13
浏览 66
已采纳

使用模块在magento 2中的每个产品页面添加脚本标记

I'm new to magento.

I'm created a module-2 module from below mentioned tutorial.

http://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/

With that module I'm injecting script into the page. But with this I'm limited to execute only on my module page i.e.,

http://localhost/magento2/helloworld

I have a sample store installed, but what should I do if I want my module to be executed on any product page.

Please help me understand. Pointing to an article would be greatly appreciated.

Thank you.

  • 写回答

2条回答 默认 最新

  • doumowu7371 2017-07-12 05:48
    关注

    Call your css and js file inside of tag in the layout xml. Example:

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
        <head>
            <link src="Namespace_YourModule::script.js"/>
            <css src="Namespace_YourModule::style.css"/>
        </head>
        <body>
        </body>
    </page>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错