商品詳細に個々のレビューが表示されますが、
レビューの一覧ページを作成し、コンテンツとしてレビューページを独立させます。
1点ものの商品とかが多く、個々ではなくサイト全体のレビューとしてアピールしたい時などに良いかもです。
管理画面から新規ページを作成します
管理画面:【デザイン管理】 ⇒ 「ページを新規入力」を選択し、必要事項を入力します。
名称:レビュー一覧
URL:review_list
共通のヘッダーを使用する/共通のフッターを使用する にチェックを入れる
tplファイルには以下を挿入
<h2><img src="<!--{$TPL_URLPATH}-->img/title/tit_product_voice.jpg" alt="この商品に対するお客様の声" /></h2> <!--{if count($arrReview) > 0}--> <ul> <!--{section name=cnt loop=$arrReview}--> <li> <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrReview[cnt].product_id|u}-->"> <img src="<!--{$smarty.const.ROOT_URLPATH}-->resize_image.php?image=<!--{$arrReview[cnt].main_list_image|sfNoImageMainList|h}-->&width=120&height=120" alt="<!--{$arrReview[cnt].name|h}-->" /></a> <a href="<!--{$smarty.const.HTTP_URL}-->products/detail.php?product_id=<!--{$arrReview[cnt].product_id|u}-->"><!--{$arrReview[cnt].name|h}--></a> <p class="voicetitle"><!--{$arrReview[cnt].title|h}--></p> <p class="voicedate"><!--{$arrReview[cnt].create_date|sfDispDBDate:false}--> 投稿者:<!--{if $arrReview[cnt].reviewer_url}--><a href="<!--{$arrReview[cnt].reviewer_url}-->" target="_blank"><!--{$arrReview[cnt].reviewer_name|h}--></a><!--{else}--><!--{$arrReview[cnt].reviewer_name|h}--><!--{/if}--> おすすめレベル:<span class="recommend_level"><!--{assign var=level value=$arrReview[cnt].recommend_level}--><!--{$arrRECOMMEND[$level]|h}--></span></p> <p class="voicecomment"><!--{$arrReview[cnt].comment|h|nl2br}--></p> </li> <!--{/section}--> </ul> <!--{/if}--> </div>
最後に「登録する」を選択。
管理画面はこれでOK!!
review_list.phpファイルを編集し、レビューの一覧を取得できるようにします
「レビュー情報の取得」と「商品ごとのレビュー情報を取得する」の
ソースを挿入します。
<!--?php require_once '../require.php'; require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; /** * ユーザーカスタマイズ用のページクラス * * 管理画面から自動生成される * * @package Page */ class LC_Page_User extends LC_Page_Ex { /** * Page を初期化する. * * @return void */ function init() { parent::init(); $masterData = new SC_DB_MasterData_Ex(); $this--->arrRECOMMEND = $masterData->getMasterData("mtb_recommend"); } /** * Page のプロセス. * * @return void */ function process() { parent::process(); $this->action(); $this->sendResponse(); } /** * Page のアクション. * * @return void */ function action() { //レビュー情報の取得 $this->arrReview = $this->lfGetReviewData(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } //商品ごとのレビュー情報を取得する function lfGetReviewData() { $objQuery =& SC_Query_Ex::getSingletonInstance(); //商品ごとのレビュー情報を取得する $col = "t1.create_date, t1.reviewer_url, t1.reviewer_name, t1.recommend_level, t1.title, t1.comment, t2.product_id, t2.name, t2.main_list_image"; $from = "dtb_review as t1 left join dtb_products as t2 using (product_id)"; $where = "t1.del_flg = 0 AND t1.status = 1 ORDER BY t1.create_date DESC"; $arrReview = $objQuery->select($col, $from, $where, $arrval); return $arrReview; } } $objPage = new LC_Page_User(); register_shutdown_function(array($objPage, 'destroy')); $objPage->init(); $objPage->process();
/user_data/review_list.php
にアクセスすると、レビューの一覧が表示されているはずです。
あとはcssなどでレイアウト調整してください。
レビュー記事が多くなった場合のページング対応もおいおいしたいと思います。
⇒22)商品レビューの一覧ページを作成する(ページング対応)
⇒hetemlのサーバでEC-CUBEインストール~公開までの道のり