我开发了一个扩展,您可以为时事通讯2 go定义一个连接id。
我需要将这个id传递给脚本skin\frontend\base\default\fekete\Newsletter2Go\js\utils.js
模板:
我的第一种方法是通过向脚本添加一个get参数将其传递给脚本。
{... Hint: I removed the rest code which is not relevant for this question ... }
(window,document,"script","skin/frontend/base/default/fekete/Newsletter2Go/js/utils.js?id=<?php echo $id ?>","n2g");我检查过这是否像这样:
alert(findGetParameter("id"));
function findGetParameter(parameterName) {
var result = null,
tmp = [];
var items = location.search.substr(1).split("&");
for (var index = 0; index < items.length; index++) {
tmp = items[index].split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
}
return result;
}但它会提醒null。
如何将id传递给脚本,而不必将整个脚本移动到模板中?
发布于 2018-07-24 15:35:37
我通过创建一个新的扩展来解决这个问题。我开发了一个控制器,然后向我的路由发出了一个XHR请求,它只返回所需的值。
https://stackoverflow.com/questions/51496286
复制相似问题