[EC-CUBE 2.11.1] レビュー一覧ページ作成 その2
さらに商品画像と商品名、商品URLへのリンクを加えたいと思います。

data/Smarty/templates/default/user_data/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=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>
<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>
html/user_data/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();
あとはSmartyテンプレートやCSSをカスタマイズして、お好みの形に合わせてください。
2011/8/10 13:41にコードの一部を修正しました。

