- PrestaShop Module Development
- Fabien Serny
- 123字
- 2021-08-05 17:12:28
Using hooks to display templates
Let's come back to our main goal here: we want to add the possibility for customers to rate and comment on products. We first have to create a form for the customers. In order to avoid HTML code in PHP files, we will use what we learned in the previous chapter:
- Create a template for the hook:
views/templates/hook/displayProductTabContent.tpl
- Use the
display
method in thehookDisplayProductTabContent
function:return $this->display(__FILE__, 'displayProductTabContent.tpl');
- Then, write a simple form in the
displayProductTabContent.tpl
template we just created:<h3 class="page-product-heading">Product Comments</h3> <div class="rte"> <form action="" method="POST" id="comment-form"> <div class="form-group"> <label for="grade">Grade:</label> <div class="row"> <div class="col-xs-4"> <select id="grade" class="form-control" name="grade"> <option value="0">-- Choose --</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </div> </div> </div> <div class="form-group"> <label for="comment">Comment:</label> <textarea name="comment" id="comment" class="form-control"></textarea> </div> <div class="submit"> <button type="submit" name="mymod_pc_submit_comment" class="button btn btn-default button-medium"><span>Send<i class="icon-chevron-right right"></i></span></button> </div> </form> </div>
In the default Bootstrap theme, CSS will automatically get applied, so, you should have a nice form displayed. On your front office, you should see this:

推薦閱讀
- 跨境電商:理論、操作與實(shí)務(wù)
- 網(wǎng)店經(jīng)營(yíng)輔助技術(shù)全攻略
- 跨境電子商務(wù)運(yùn)營(yíng):速賣通 亞馬遜 eBay
- 新企業(yè)社會(huì)網(wǎng)絡(luò)構(gòu)建的效應(yīng)機(jī)制分析:基于效率和效果的實(shí)證研究
- 農(nóng)產(chǎn)品電商運(yùn)營(yíng)實(shí)戰(zhàn)(微課版)
- 跨境電商:平臺(tái)運(yùn)營(yíng)實(shí)戰(zhàn)指南
- 社群商業(yè):社群經(jīng)濟(jì)時(shí)代的掘金法則
- 贏在互聯(lián)網(wǎng)思維:15位網(wǎng)絡(luò)創(chuàng)富精英如是說
- PrestaShop Module Development
- 大變革:互聯(lián)網(wǎng)重構(gòu)商業(yè)模式
- Hyperledger Fabric技術(shù)內(nèi)幕:架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- 誰是下一百個(gè)億萬富翁:移動(dòng)互聯(lián)網(wǎng)時(shí)代的造富機(jī)會(huì)
- 二維碼的秘密:智能手機(jī)時(shí)代的新營(yíng)銷寶典
- 電子商務(wù)實(shí)驗(yàn)指導(dǎo)
- “微商創(chuàng)業(yè)女王”丁小航手把手教你做微商