前回の記事で、レビューの一覧ページを作成する方法を紹介しましたが、一覧だけにやはりページング機能もつけたいので、ちょっとファイルを改変します。
review_list.phpファイルを編集します
管理画面から新規ページを作成した時の「review_list.php」を編集します。(/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() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->arrForm = $_REQUEST; //現在のページ番号取得 $this->tpl_pageno = $this->arrForm['pageno']; //レビューの件数取得 $linemax = $objQuery->count("dtb_review", "del_flg = 0 AND status = 1 ORDER BY create_date DESC"); $this->tpl_linemax = $linemax; //1ページの表示件数取得 $page_max = SC_Utils_Ex::sfGetSearchPageMax($arrForm['search_page_max']); //$page_max = 3; //確認用にハードコードしました //ページ送りの取得 $urlParam = "pageno=#page#"; $objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $linemax, $page_max,'fnNaviPage', NAVI_PMAX, $urlParam); $this->arrPagenavi = $objNavi->arrPagenavi; //表示文字列アサイン $this->tpl_strnavi = $objNavi->strnavi; //開始行番号取得 $startno = $objNavi->start_row; // 取得範囲の指定(開始行番号、行数のセット) $objQuery->setLimitOffset($page_max, $startno); //商品ごとのレビュー情報を取得する $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"; $this->arrReview = $objQuery->select($col, $from, $where, $arrval); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } $objPage = new LC_Page_User(); register_shutdown_function(array($objPage, 'destroy')); $objPage->init(); $objPage->process();
tplファイルには以下を挿入
<!--{$tpl_strnavi}--> <h2><img src="<!--{$TPL_URLPATH}-->img/title/tit_product_voice.jpg" alt="この商品に対するお客様の声" /></h2> <!--{if count($arrReview) > 0}--> <div> <!--{section name=cnt loop=$arrReview}--> <div style="margin-bottom:30px;" class="clearfix"> <p class="voicedate" style="margin:10px 0;"><!--{$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="voiceimg" style="float:left;"><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></p> <div style="float:left;margin-left:10px;"> <p class="voiceimg"><a href="<!--{$smarty.const.HTTP_URL}-->products/detail.php?product_id=<!--{$arrReview[cnt].product_id|u}-->"><!--{$arrReview[cnt].name|h}--></a></p> <p class="voicetitle"><!--{$arrReview[cnt].title|h}--></p> <p class="voicecomment"><!--{$arrReview[cnt].comment|h|nl2br}--></p> </div> </div> <!--{/section}--> </div> <!--{/if}-->
問題なければ一覧ページでページングが表示されているはずです。
※レビューが10個以上ければページングされません。
今回はphpファイルを修正しましたが、その他にはjsなどでページングみたくしてもいいかもです。
※スマホ用には対応していないので、後日導入したいと思います。
⇒23)新着情報の一覧ページを作成する(ページング対応)
⇒hetemlのサーバでEC-CUBEインストール~公開までの道のり
I do not even understand how I finished up right here, but I thought this publish was
once good. I don’t realize who you might be but definitely you’re
going to a well-known blogger for those who are not already.
Cheers!
Préstamos sin aval para que mejore su calidad de vida.