官术网_书友最值得收藏!

  • PrestaShop Module Development
  • Fabien Serny
  • 392字
  • 2021-08-05 17:12:27

Changing the position of your module on a hook

You have to know that a module attached to a hook has a position. The positions represent the order in which the modules are called. When you attach a module to a hook, the module will be automatically set in the last position. However, you will be able, for most of the hooks, to change the order of the modules in PrestaShop's back office (by navigating to Main menu | Modules | Positions).

In our case, if you didn't install any other module than mymodcomments since you installed your shop, you should have only one other module attached to the hook: displayProductTabContent that results in Product Comments (which is a module similar to the one we are creating):

As you can see, the position number and arrows are displayed for each module attached to this hook. You can change the position either by clicking on the position of My Module of product comments, and without releasing your click, drag it up just above the Product Comments module, or by clicking on one of the arrows. The new position will then be automatically saved.

If you go back to your front office, you will see that Display me on product page is now displayed above the No customer comments for the moment content:

This was just to show you how positions work, but currently, we do not need to keep the Product Comments native module. So you can uninstall it or unhook it.

To unhook a module, you just have to click on the arrow on the right of the Edit button and select Unhook:

It will unregister the module from the hook; however, in the case of the Product Comments module, it will still be attached to the displayProductTab hook.

Removing a module from one hook can be interesting in some cases, but if you want to remove the module from all the hooks, the best way is to uninstall it. So, go and uninstall the Product Comments module.

Note

You can also attach a module to a hook manually by using the Transplant a module button at the top of your page. However, the module has to contain the method associated with the hook on which you want to attach the module (for example, the hookDisplayProductTabContent class method for the displayProductTabContent hook).

主站蜘蛛池模板: 沂南县| 孟州市| 新安县| 阿图什市| 象山县| 马鞍山市| 方正县| 额敏县| 思茅市| 宜阳县| 搜索| 霍城县| 云浮市| 新田县| 凤城市| 岑巩县| 东宁县| 儋州市| 缙云县| 南宫市| 水富县| 鹤壁市| 铜川市| 铜鼓县| 昭苏县| 瓦房店市| 郑州市| 巩留县| 怀来县| 池州市| 高青县| 布尔津县| 鹤庆县| 介休市| 常熟市| 怀仁县| 抚顺县| 新营市| 清原| 视频| 麻阳|