質問 > フロント機能 > 「メインビジュアルスライドショープラグイン」のランダム表示がしたいです。 |
フロント機能
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
NB0 |
投稿日時: 2017/4/5 18:24
対応状況: −−−
|
新米 登録日: 2014/11/2 居住地: 投稿: 10 |
「メインビジュアルスライドショープラグイン」のランダム表示がしたいです。 ----------------------------------
EC-CUBE 2.13.2 サーバーOS FreeBSD 9.1-RELEASE-p24 amd64 DBサーバー MySQL 5.5 WEBサーバー Apache/2.2.31 PHP 5.6.18 ---------------------------------- お世話になります。 「メインビジュアルスライドショープラグイン」 http://www.ec-cube.net/products/detail.php?product_id=804 このプラグインで表示されるスライドショーを、アクセスごとに登録されている商品をランダムで表示したいのですが、どのようなカスタマイズを施せば実現できますでしょうか? メインビジュアルスライドショープラグインで登録できる5つの商品を、順番固定ではなくアクセスごとにランダムで表示したいという事です。 わかる方、どうかご教授いただけますと幸いです。 よろしくお願い致します。 |
umebius |
投稿日時: 2017/4/5 23:05
対応状況: −−−
|
神 登録日: 2016/7/22 居住地: 投稿: 2085 |
Re: 「メインビジュアルスライドショープラグイン」のランダム表示がしたいです。 具体的な方法ではないですが、スライドショーのデータ(ファイル名など)はDBのテーブルに登録されているはずですので、その取得部分を探し出して、phpでランダムにソートしてやればOKだと思います。
MYSQLならSQLにORDER BY RAND()などカスタマイズしても良いと思います。
|
NB0 |
投稿日時: 2017/4/8 17:06
対応状況: −−−
|
新米 登録日: 2014/11/2 居住地: 投稿: 10 |
Re: 「メインビジュアルスライドショープラグイン」のランダム表示がしたいです。 ありがとうございます。
おっしゃる通りrandom関数で表示部をランダム表示することに成功しました。 しかし、メインイメージとサムネイルイメージが一致しないという不具合が発生しております。 サムネイルイメージをクリックすれば対応したメインイメージに変わるというデフォルトの機能ですが、 function lfGetMainImageList() function lfGetMainImageThumbnailList() この2つの関数の取得部をrandomにしたので、それぞれがランダム取得という事で一致しないことは必然といえばそうですが…。 これをメインイメージとサムネイルイメージを一致させる方法はありますでしょうか? 念のためコードを記載します。 function action() { $this->arrMainImageListFree = $this->lfGetMainImageList(); $this->arrMainImageOption = $this->lfGetMainImageOption(); $this->tpl_peger = $this->tplPeger(); $this->tpl_peger_tag = $this->tplPegerTag(); $PThumnaiList = $this->lfGetMainImageThumbnailList(); } function lfGetMainImageList() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = "*"; $where = "del_flg = 0"; $table = "plg_dtb_main_image"; $objQuery->setOrder("random()"); $arrRet = $objQuery->select($col, $table, $where); return $arrRet; } function lfGetMainImageThumbnailList() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = "main_image_image2,main_image_title1"; $where = "del_flg = 0"; $table = "plg_dtb_main_image"; $objQuery->setOrder("random()"); $arrRet = $objQuery->select($col, $table, $where); foreach ($arrRet as $key => $ThumnaiList) { $PThumnaiList .= "<div><img class=\"peger_thumbnail\" src=\"" . IMAGE_SAVE_URLPATH . $ThumnaiList['main_image_image2'] . "\" alt=\"" . $ThumnaiList['main_image_title1'] . "\"/></div>"; } return $PThumnaiList; } function lfGetMainImageOption() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = "*"; $where = ""; $table = "plg_dtb_main_image_option"; $arrRet = $objQuery->select($col, $table, $where); return $arrRet; } function tplPeger() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = "main_image_peger"; $where = ""; $table = "plg_dtb_main_image_option"; $arrRet = $objQuery->select($col, $table, $where); if($arrRet[0]['main_image_peger'] == "number"){ $div = "data-cycle-pager=\"#custom-pager\" data-cycle-pager-template=\"<span><a href=#> {{slideNum}} </a></span>\""; }elseif($arrRet[0]['main_image_peger'] == "thumbnail"){ $div = "data-cycle-pager=\"#adv-custom-pager\" data-cycle-pager-template=\"\""; } return $this->tpl_peger = $div; } function tplPegerTag() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = "main_image_peger"; $where = ""; $table = "plg_dtb_main_image_option"; $arrRet = $objQuery->select($col, $table, $where); if($arrRet[0]['main_image_peger'] == "number"){ $tag = "<div id=\"custom-pager\" class=\"center cycle-pager\"></div>"; }elseif($arrRet[0]['main_image_peger'] == "thumbnail"){ $tag = "<div id=\"adv-custom-pager\" class=\"center cycle-pager\">" . $this->lfGetMainImageThumbnailList() . "</div>"; }elseif($arrRet[0]['main_image_peger'] == "standerd"){ $tag = "<p class=\"cycle-pager\"></p>"; } return $this->tpl_peger_tag = $tag; } function lfGetMainImageList() function lfGetMainImageThumbnailList() の中の $objQuery->setOrder("rank DESC"); を $objQuery->setOrder("random()"); に変えました。 よろしくお願い致します。 |
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | トップ |