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

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:

  1. Create a template for the hook:
    views/templates/hook/displayProductTabContent.tpl
  2. Use the display method in the hookDisplayProductTabContent function:
    return $this->display(__FILE__, 'displayProductTabContent.tpl');
  3. 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:

主站蜘蛛池模板: 通山县| 申扎县| 富平县| 策勒县| 乌拉特中旗| 鹰潭市| 渑池县| 阿鲁科尔沁旗| 烟台市| 哈尔滨市| 牙克石市| 大方县| 泌阳县| 高唐县| 永和县| 肃北| 津市市| 锡林郭勒盟| 闵行区| 苗栗市| 贺州市| 巨鹿县| 马龙县| 西乌珠穆沁旗| 祁阳县| 扶风县| 社会| 兴业县| 米泉市| 浦江县| 泾阳县| 博湖县| 汾阳市| 清新县| 新平| 西乡县| 柞水县| 英德市| 张家界市| 来凤县| 东海县|