0

我正在使用 Prestashop v1.6。

当我导航到此 url 路线时:

localhost/dumb/url

我想添加这个脚本

src="localhost/dumb/url/script.js",

我只需要在该 URL 上公开该脚本。

我想要什么:一步一步的指南来了解我应该做什么

4

1 回答 1

0

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');
}
于 2019-09-30T09:58:50.573 回答