- 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:

推薦閱讀
- 抖音運營變現(xiàn)手冊
- 社群營銷(微課版)
- 移動社群營銷實戰(zhàn)法則、技巧與經(jīng)典案例
- 社群營銷
- 網(wǎng)店運營(提高版·第2版)
- 1000個鐵粉:打造個人品牌的底層邏輯
- 電商多平臺運營實戰(zhàn):淘寶、京東、拼多多、抖音
- 電商數(shù)據(jù)分析與數(shù)據(jù)化運營
- 電子商務(wù)海外業(yè)務(wù)指南
- B2B網(wǎng)絡(luò)交易實務(wù)
- 中歐電子商務(wù)績效評估比較研究
- PrestaShop Module Development
- 直播營銷與運營(微課版)
- 決勝移動終端:移動互聯(lián)時代影響消費者決策的6大關(guān)鍵
- 從零開始做運營