【问题标题】:Magento 2 Theme hardcoded google maps api url'sMagento 2 Theme 硬编码谷歌地图 api url
【发布时间】:2019-01-18 16:15:08
【问题描述】:

我正在配置一个 magento 2.1.7 部署,使用 IIS 和 php。

我正在运行 TemplateMonster (Theme) 的主题

我已将我的商店配置为通过 SSL 运行,但我收到混合内容警告,因为有一些 JS 脚本试图通过 http 加载 google maps api 引用。这发生在商店的所有页面上。页面是动态创建的,因此我无法追踪代码是从哪里注入的。

对于我的生活,我无法找到在模板或 magento 源中实现它的位置。我已经浏览了所有内容块和页面,但我找不到它。我的 magento 主题技能是 0,所以我不知道主题开发人员会在哪里添加混合到每个渲染页面的代码。

我的警告:

Mixed Content: The page at '***.html' was loaded over HTTPS, but requested an insecure script 'http://maps.googleapis.com/maps/api/js?sensor=true&callback=initialize'. This content should also be served over HTTPS.

来源被报告为页面不存在(动态生成)

这是导致我的问题的代码块,我只是找不到它!

function loadScript() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.googleapis.com/maps/api/js?sensor=true&callback=initialize";
    document.body.appendChild(script);
}

有什么想法吗?

【问题讨论】:

  • 对 googleapis 的所有主题文件执行 grep / 搜索,以找到加载主题的位置。如果找不到,则主题不是问题(可能是数据库值?)。
  • 啊,我忘了提,我在配置了 PHP 的 IIS 上。不幸的是没有grep。我确实尝试过 Windows 搜索(包括文件内容),但我们都知道它的效果如何......
  • 谢谢!那成功了……我找到了罪魁祸首。我将在下面添加解决方案以供参考。谢谢一堆。

标签: php templates magento magento2 magento2.1


【解决方案1】:

根据上面@sakura Kinomoto 的建议,我使用工具findstr 来定位包含我要查找的文本的文件。

有问题的文件是: wwwroot\app\code\TemplateMonster\GoogleMap\view\frontend\templates\init.phtml

【讨论】:

    猜你喜欢
    • 2011-08-28
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 2012-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多