1

我正在为 prestashop 1.5 开发一个新模块,我需要在产品编辑页面上的“组合”选项卡中添加一行 html 代码。我在 template/controllers/products/combinations.tpl 中找不到任何特定的钩子所以我决定使用 jQuery 动态添加这一行。

作为临时解决方案,我使用了 displayAdminProductsExtra 挂钩。我在包含的.tpl 中有一个脚本,它在左侧隐藏了额外的选项卡并将reuired 行添加到“组合”选项卡中。

显然,这不是最好的解决方案。首先,加载额外的选项卡内容需要 1-2 秒,因此左侧的选项卡会延迟隐藏。其次,这种方式看起来不正确。

所以我的问题是:加载“组合”选项卡时运行脚本的最佳方式是什么?

如果有更好的方法将一行 html 代码添加到“组合”选项卡中,那就更好了:)

4

1 回答 1

1

您确实可以通过覆盖其模板将 html 添加到组合选项卡。

为此,您必须在模块中创建一个文件:
modules/your_module/override/controllers/admin/templates/products/combinations.tpl

在此文件中复制以下代码:

{include file="controllers/products/combinations.tpl"}

// Add here your html code
<p style="color:red;text-align:center;">Add a text after the form</p>

不幸的是,当人们安装您的模块时,Prestashop 不会自动将该文件复制到需要处理的位置。

要复制此文件,您必须在安装功能中添加本主题中可用的代码:http: //www.prestashop.com/forums/topic/269657-resolu-overrider-template-admin-depuis-un-module /?p=1349110

于 2014-03-23T16:57:25.063 回答