EC-CUBE:売れ筋ランキング 携帯表示(MySQL・PostgreSQL両対応)

ここで紹介している内容は、「EC-CUBE:売れ筋ランキングを携帯で表示する」とは異なるもので、MySQL・PostgreSQLの両方に対応しています。

EC-CUBE:売れ筋ランキング(MySQL・PostgreSQL両対応)EC-CUBE:売れ筋ランキング スマートフォン表示(MySQL・PostgreSQL両対応)が作成されていることが条件。

1 ランキング表示専用のページが必要となるが、下記スマートフォン用のファイルを利用するので、新規に作成する必要はない。
■html/sphone_ranking.php
■data/class_extends/page_extends/LC_Page_Sphone_ranking_Ex.php
■data/class/pages/LC_Page_Sphone_ranking.php
■data/Smarty/templates/sphone/sphone_ranking.tpl

2 データベースに携帯用のページを登録
——————————————————-
テーブル:dtb_pagelayout
device_type_id:1
page_id:38
page_name:ランキングページ
url:sphone_ranking.php
filename:sphone_ranking
header_chk:1
footer_chk:1
edit_flg:2
author:NULL
description:NULL
keyword:NULL
update_url:NULL
create_date:作成日
update_date:作成日
——————————————————-

3 ブロックを作成する(PC用のranking.tplが作成済みであることが前提)

(1) ■data/Smarty/templates/mobile/frontparts/bloc/ranking.tpl

 <!-- ▼ランキング -->
 <!--{if count($arrBestProducts) > 0}-->
 <h3>売れ筋ランキング</h3><br>
 <!--{section name=cnt loop=$arrBestProducts}-->
 第<!--{$arrBestProducts[cnt].rank|h}-->位:<a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrBestProducts[cnt].product_id|u}-->.html"><!--{$arrBestProducts[cnt].name|h}--></a><br>
 <center><a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrBestProducts[cnt].product_id|u}-->.html"><img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrBestProducts[cnt].main_list_image|h}-->"></a></center>
 <!--{$arrarrBestProducts[cnt].main_list_comment|h|nl2br}--><br>
 <!--{assign var=price01 value=`$arrBestProducts[cnt].price01_min`}-->
 <!--{assign var=price02 value=`$arrBestProducts[cnt].price02_min`}-->
 販売価格(税込):<!--{$price02|sfCalcIncTax:$arrInfo.tax:$arrInfo.tax_rule|number_format}-->円
 <hr>
 <!--{/section}-->
 <!--{else}-->
 <h3>売れ筋ランキング</h3><br>
 現在、売れ筋ランキングのデータがありません。<br><br>
 <!--{/if}-->
 <!-- ▲ランキング -->

(2) データベースにブロックを登録
——————————————————-
テーブル:dtb_bloc
device_type_id:1
bloc_id:5
bloc_name:ランキング
tpl_path:ranking.tpl
filename:ranking
create_date:作成日
update_date:作成日
php_path:frontparts/bloc/ranking.php
deletable_flg:0
——————————————————-

4 ランキングページへのリンクを作成(ランキングページを開いたときは表示させない)

■data/Smarty/templates/mobile/frontparts/bloc/category.tpl(最上部の前に追加)
(ランキングページを開くためには、「カテゴリ」ブロックを配置しておかなければならない)

 <!--{assign var=sphone_ranking  value="`$smarty.const.ROOT_URLPATH`sphone_ranking.php"}-->
 <!--{if $smarty.server.PHP_SELF==$sphone_ranking}-->
 <!--{else}-->
 <hr>
 <br>
 <center><a href="<!--{$smarty.const.MOBILE_TOP_URLPATH}-->sphone_ranking.php">売れ筋ランキングを見る</a></center>
 <br>
 <hr>
 <!--{/if}-->