まず管理画面にログインして、デザイン管理>PC>レイアウト設定 から、ページを新規入力します。
URLは review_list.php として、以下のコードを貼り付けて保存します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<div id="customervoice_area"> <h2><img src="<!--{$TPL_URLPATH}-->img/title/tit_product_voice.jpg" alt="この商品に対するお客様の声" /></h2> <!--{if count($arrReview) > 0}--> <ul> <!--{section name=cnt loop=$arrReview}--> <li> <!--{$arrReview[cnt].title|h}--> <!--{$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> <!--{$arrReview[cnt].comment|h|nl2br}--> </li> <!--{/section}--></ul> <!--{/if}--></div> |
次に、html/user_data/review_list.php を開いて、次のように修正します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<!--?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(); |
data/Smarty/templates/default/user_data/review_list.tpl を以下のように変更します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<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=40&height=40" 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> <!--{$arrReview[cnt].title|h}--> <!--{$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> <!--{$arrReview[cnt].comment|h|nl2br}--> </li> <!--{/section}--></ul> <!--{/if}--> |
以上。
ブロック化は以下。
デザイン管理>PC>ブロックの設定新規ブロックで下記を作成。
ブロック名:お客様の声一覧
ファイル名:review_list_bloc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<div id="customervoice_area"> <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=40&height=40" 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> <!--{$arrReview[cnt].title|h}--> <!--{$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> <!--{$arrReview[cnt].comment|h|nl2br}--> </li> <!--{/section}--></ul> <!--{/if}--></div> |
トップページのブロックで表示する場合、html直下のindex.php下記のような感じで書き換え。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
require_once './require.php'; require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Index_Ex.php'; // }}} // {{{ generate page //$objPage = new LC_Page_Index_Ex(); //register_shutdown_function(array($objPage, "destroy")); //$objPage->init(); //$objPage->process(); /** * ユーザーカスタマイズ用のページクラス * * 管理画面から自動生成される * * @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(); |
基本的には同じ作業。
画像とかは適当にかえましょう。
(レビュー自体未投稿だと空欄なので適当に用意しておきましょう。)