javascript - 将自定义 js 添加到特定的 prestashop 页面
问题描述
我正在使用 Prestashop v1.6。
当我导航到此 url 路线时:
localhost/dumb/url
我想添加这个脚本
src="localhost/dumb/url/script.js",
我只需要在该 URL 上公开该脚本。
我想要什么:一步一步的指南来了解我应该做什么
解决方案
Standard way:
Your URL (localhost/dumb/url) must have a controller created by your module. you can add your js file using this controller
$this->addJs(__PS_BASE_URI__.'/dumb/url/script.js');
Not recommended way:
Add this code to FrontController.php (or override this controller):
if (pathinfo($_SERVER['REQUEST_URI'])['dirname'] == '/dumb/url') {
$this->addJs(__PS_BASE_URI__.'/dumb/url/script.js');
}
推荐阅读
- ionic-framework - 我想在 Branch.io 中使用相同帐户和另一个帐户设置旧域名
- node.js - Node.JS 服务器、WebSockets 和 HTTP 与 HTTPS
- python - 我无法在列表中填充字典
- javascript - OAuth 弹窗跨域安全 React.js
- c# - 使用半正弦公式计算地理坐标距离会给出错误的输出
- python - 使用python从UDP数据包中删除前几个字节
- r - 将条形图中的 y 轴转换为时间刻度
- html - 边距:0 自动;不在父级中居中 div
- vmware-clarity - 卡片中的内容居中
- java - 在 REST 中,在嵌套资源中设计分页的有效方法是什么?