管理画面>デザイン管理>PCに「おすすめ表示管理」ページを新規作成し、表示番号を選択することで、「その他のオススメ商品」の表示パターンを変更できるようにする。
「自動スライド」「縦2列横並び」「縦3列横並び」「縦4列横並び」の4パターンから選択できる。
▼ここでのカスタマイズファイルをすべてダウンロードできます。
必要な箇所だけコピーしてご利用ください。
他のカスタマイズも含まれている場合がありますので、ファイルの上書きは絶対におやめください。
こちらから(facebookユーザーのみ)
(1)データベースに新しいテーブルを作成する
① テーブル(mtb_detailsonota_line)を作成する
【MySQL・PostgreSQL】
CREATE TABLE mtb_detailsonota_line ( id smallint, name text, rank smallint NOT NULL DEFAULT 0, PRIMARY KEY (id) );
② テーブル(mtb_detailsonota_line)にデータを登録する。
INSERT INTO mtb_detailsonota_line (id, name, rank) VALUES (1, '1', 0); INSERT INTO mtb_detailsonota_line (id, name, rank) VALUES (2, '2', 1); INSERT INTO mtb_detailsonota_line (id, name, rank) VALUES (3, '3', 2); INSERT INTO mtb_detailsonota_line (id, name, rank) VALUES (4, '4', 3)
(2)データベース「dtb_baseinfo」テーブルにカラムを追加。
ALTER TABLE dtb_baseinfo ADD detailsonota_line smallint NOT NULL DEFAULT 2
(3)管理画面用のページを新規作成
① ■html/admin/design/detailsonota_line.php
<?php // {{{ requires require_once '../require.php'; require_once CLASS_EX_REALDIR . 'page_extends/admin/design/LC_Page_Admin_Detailsonota_Line_Ex.php'; // }}} // {{{ generate page $objPage = new LC_Page_Admin_Detailsonota_Line_Ex(); register_shutdown_function(array($objPage, 'destroy')); $objPage->init(); $objPage->process(); ?>
② ■data/class_extends/page_extends/admin/design/LC_Page_Admin_Detailsub_Line_Ex.php.php
<?php // {{{ requires require_once CLASS_REALDIR . 'pages/admin/design/LC_Page_Admin_Detailsonota_Line.php'; class LC_Page_Admin_Detailsonota_Line_Ex extends LC_Page_Admin_Detailsonota_Line { // }}} // {{{ functions /** * Page を初期化する. * * @return void */ function init() { parent::init(); } /** * Page のプロセス. * * @return void */ function process() { parent::process(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } } ?>
③ ■data/class/pages/admin/design/LC_Page_Admin_Detailsub_Line.php
<?php // {{{ requires require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; class LC_Page_Admin_Detailsonota_Line extends LC_Page_Admin_Ex { // }}} // {{{ functions /** * Page を初期化する. * * @return void */ function init() { parent::init(); $this->tpl_mainpage = 'design/detailsonota_line.tpl'; $this->tpl_subno = 'detailsonota_line'; $this->tpl_mainno = 'design'; $masterData = new SC_DB_MasterData_Ex(); $this->arrLine = $masterData->getMasterData('mtb_detailsonota_line'); $this->tpl_maintitle = 'デザイン管理'; $this->tpl_subtitle = 'PC>商品詳細その他オススメ表示'; } /** * Page のプロセス. * * @return void */ function process() { $this->action(); $this->sendResponse(); } /** * Page のアクション. * * @return void */ function action() { $objDb = new SC_Helper_DB_Ex(); $objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($objFormParam); $objFormParam->setParam($_POST); $cnt = $objDb->sfGetBasisCount(); if ($cnt > 0) { $this->tpl_mode = 'update'; } else { $this->tpl_mode = 'insert'; } if(!empty($_POST)) { // 入力値の変換 $objFormParam->convParam(); $this->arrErr = $this->lfCheckError($objFormParam); if(count($this->arrErr) == 0) { switch($this->getMode()) { case 'update': $this->lfUpdateData($objFormParam->getHashArray()); // 既存編集 break; case 'insert': $this->lfInsertData($objFormParam->getHashArray()); // 新規作成 break; default: break; } // 再表示 $this->tpl_onload = "window.alert('商品詳細その他オススメ表示設定が完了しました。');"; } } else { $arrCol = $objFormParam->getKeyList(); // キー名一覧を取得 $col = SC_Utils_Ex::sfGetCommaList($arrCol); $arrRet = $objDb->sfGetBasisData(true, $col); $objFormParam->setParam($arrRet); } $this->arrForm = $objFormParam->getFormParamList(); } /** * デストラクタ. * * @return void */ function destroy() { parent::destroy(); } /* パラメーター情報の初期化 */ function lfInitParam(&$objFormParam) { $objFormParam->addParam("商品詳細その他オススメ表示", "detailsonota_line", INT_LEN, 'n', array("MAX_LENGTH_CHECK")); } function lfUpdateData($sqlval) { $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $objQuery =& SC_Query_Ex::getSingletonInstance(); // UPDATEの実行 $ret = $objQuery->update("dtb_baseinfo", $sqlval); } function lfInsertData($sqlval) { $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $objQuery =& SC_Query_Ex::getSingletonInstance(); // INSERTの実行 $ret = $objQuery->insert("dtb_baseinfo", $sqlval); } /* 入力内容のチェック */ function lfCheckError(&$objFormParam) { // 入力データを渡す。 $arrRet = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrRet); $objErr->arrErr = $objFormParam->checkError(); return $objErr->arrErr; } } ?>
④ ■data/Smarty/templates/admin/design/detailsonota_line.tpl
<form name="form1" id="form1" method="post" action=""> <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" /> <input type="hidden" name="mode" value="<!--{$tpl_mode}-->" /> <div id="design" class="contents-main"> <table class="form"> <tr> <th>表示番号</th> <td> <select class="top" name="detailsonota_line" style="<!--{if $arrErr.line != ""}-->background-color: <!--{$smarty.const.ERR_COLOR}-->;<!--{/if}-->" > <option value="" selected="selected">選択</option> <!--{html_options options=$arrLine selected=$arrForm.detailsonota_line}--> </select> </td> </tr> </tr> </table> <div class="btn-area"> <ul> <li><a class="btn-action" href="javascript:;" onclick="fnFormModeSubmit('form1', '<!--{$tpl_mode}-->', '', ''); return false;"><span class="btn-next">この内容で登録する</span></a></li> </ul> </div> <div class="image_area"> <div class="text"> <div class="red bold">【表示番号 1】</div><br />スライド表示。 </div> <div class="image"> <img src="<!--{$TPL_URLPATH}-->img/design/301.png" alt="" /> </div> <div class="clear"></div> </div> <div class="image_area"> <div class="text"> <div class="red bold">【表示番号 2】</div><br />縦2列で表示。 </div> <div class="image"> <img src="<!--{$TPL_URLPATH}-->img/design/302.png" alt="" /> </div> <div class="clear"></div> </div> <div class="image_area"> <div class="text"> <div class="red bold">【表示番号 3】</div><br />縦3列で表示。 </div> <div class="image"> <img src="<!--{$TPL_URLPATH}-->img/design/303.png" alt="" /> </div> <div class="clear"></div> </div> <div class="image_area"> <div class="text"> <div class="red bold">【表示番号 4】</div><br />縦4列で表示。 </div> <div class="image"> <img src="<!--{$TPL_URLPATH}-->img/design/304.png" alt="" /> </div> <div class="clear"></div> </div> </div> </form>
⑤ ■data/Smarty/templates/admin/design/subnavi.tpl←リンクを追加
<!--▼商品詳細その他オススメ表示--> <li<!--{if $tpl_subno == 'detailsonota_line'}--> class="on"<!--{/if}--> id="navi-design-detailsonota_line"><a href="<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->design/detailsonota_line.php"><span>商品詳細その他オススメ表示</span></a></li> <!--▲商品詳細その他オススメ表示-->
⑥ ■html/user_data/packages/admin/css/admin_contents.css
1205行あたり 「デザイン管理」の箇所に追加
/*おすすめ表示管理・商品一覧ページ表示管理・商品詳細ページサブ情報表示管理・商品詳細その他オススメ表示*/ #design .image_area { clear:both; border:#CCC 1px solid; padding:10px; margin-bottom:15px; font-size:150%; } #design .image_area .text { float:left; width:150px; margin-right:10px; } #design .image_area .image { float:right; } .clear { clear:both; }
⑦ 管理画面用のイメージを追加
■html/user_data/packages/admin/img/designフォルダを作成し、下記イメージを置く。
上から、301.png 302.png 303.png 304.png
① jQuery caroufredselを利用する。
http://caroufredsel.frebsite.nl/
■html/js/jquery.caroufredsel(追加)
■data/Smarty/templates/default/site_frame.tpl
<!--caroufredsel--> <script type="text/javascript" src="<!--{$smarty.const.ROOT_URLPATH}-->js/jquery.caroufredsel/jquery.carouFredSel-5.6.4.js"></script>
② ■data/Smarty/templates/default/detail.tpl
<!--▼関連商品--> <!--{if $arrRecommend}--> <!--{assign var=detailsonota_line value=$arrSiteInfo.detailsonota_line|h}--> <div id="relation_area"> <h2><img src="<!--{$TPL_URLPATH}-->img/title/tit_product_recommend.jpg" alt="その他のオススメ商品" /></h2> <!-- ***** ▼表示番号1 ***** --> <!--{if $detailsonota_line == 1}--> <script type="text/javascript"> $(function() { $('#carousel_detailsonota').carouFredSel({ align: false, items: 5, scroll: { items: 1, duration: 2000, pauseDuration: 0, easing: 'linear', pauseOnHover: 'immediate' } }); var $w = $(window); $w.bind('resize.example', function() { var nw = $w.width(); if (nw < 990) { nw = 990; } $('#carousel_detailsonota').width(nw * 3); $('#carousel_detailsonota').parent().width(nw); }).trigger('resize.example'); }); </script> <div id="relation_<!--{$detailsonota_line}-->"> <div id="carousel_detailsonota"> <!--{foreach from=$arrRecommend item=arrItem name="arrRecommend"}--> <div> <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}--><!--{if $smarty.const.STATIC_URL == true}-->.html<!--{/if}-->"> <img src="<!--{$smarty.const.ROOT_URLPATH}-->resize_image.php?image=<!--{$arrItem.main_list_image|sfNoImageMainList|h}-->" alt="<!--{$arrItem.name|h}-->" /> </a> <!--{assign var=price02_min value=`$arrItem.price02_min_inctax`}--> <!--{assign var=price02_max value=`$arrItem.price02_max_inctax`}--> <span class="price"> <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}--><!--{if $smarty.const.STATIC_URL == true}-->.html<!--{/if}-->"><!--{$arrItem.name|h}--></a> <br /> <!--{if $price02_min == $price02_max}--> <!--{$price02_min|number_format}--> <!--{else}--> <!--{$price02_min|number_format}-->~<!--{$price02_max|number_format}--> <!--{/if}-->円 </span> </div> <!--{/foreach}--> </div> <div class="clear"></div> </div> <!--{/if}--> <!-- ***** ▼表示番号2~4 ***** --> <!--{if $detailsonota_line == 2 || $detailsonota_line == 3 || $detailsonota_line == 4}--> <div id="relation_<!--{$detailsonota_line}-->"> <!--{foreach from=$arrRecommend item=arrItem name="arrRecommend"}--> <div class="product_item"> <div class="productImage"> <a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}--><!--{if $smarty.const.STATIC_URL == true}-->.html<!--{/if}-->"> <img src="<!--{$smarty.const.ROOT_URLPATH}-->resize_image.php?image=<!--{$arrItem.main_list_image|sfNoImageMainList|h}-->&width=65&height=65" alt="<!--{$arrItem.name|h}-->" /></a> </div> <!--{assign var=price02_min value=`$arrItem.price02_min_inctax`}--> <!--{assign var=price02_max value=`$arrItem.price02_max_inctax`}--> <div class="productContents"> <h3><a href="<!--{$smarty.const.P_DETAIL_URLPATH}--><!--{$arrItem.product_id|u}--><!--{if $smarty.const.STATIC_URL == true}-->.html<!--{/if}-->"><!--{$arrItem.name|h}--></a></h3> <p class="sale_price"><span class="title"><!--{$smarty.const.SALE_PRICE_TITLE}-->(税込):</span><span class="price"> <!--{if $price02_min == $price02_max}--> <!--{$price02_min|number_format}--> <!--{else}--> <!--{$price02_min|number_format}-->~<!--{$price02_max|number_format}--> <!--{/if}-->円</span></p> <p class="mini"><!--{$arrItem.comment|h|nl2br}--></p> </div> </div> <!--{if $smarty.foreach.arrRecommend.iteration % $detailsonota_line === 0}--> <div class="clear"></div> <!--{/if}--> <!--{/foreach}--> </div> <div class="clear"></div> <!--{/if}--> </div> <!--{/if}--> <!--▲関連商品-->
③ ■html/user_data/packages/default/css/contents.css
商品部分はbloc.cssのおすすめ商品から切り離してあります。
「関連商品」の部分をすべて書き換える。
/* 関連商品(商品部分はbloc.cssのおすすめ商品から切り離し、ここでの設定が反映されます。) ----------------------------------------------- */ /* 共通 ----------------------------------------------- */ #relation_area { clear: both; padding: 35px 0 0 0; } #relation_area h2 { border-top: solid 1px #f90; background: url('../img/background/bg_tit_sub_01.jpg') repeat-x left bottom; padding: 5px 0 8px 10px; font-size: 14px; } #relation_area .clear { padding-top:10px; margin-bottom:10px; border-bottom:#eee 1px solid; } #relation_area .product_item h3 { font-size: 100%; font-weight: normal; } #relation_1, #relation_2, #relation_3, #relation_4 { padding-top:15px; } #relation_area .product_item .productImage img { padding:3px; border:#CCC 1px solid; } /*「販売価格(税込): 」という文言の表示・非表示*/ #relation_1 .sale_price .title { display:none; /*「販売価格(税込): 」表示→display:inline; 非表示→display:none; */ } #relation_2 .sale_price .title { display:inline; /*「販売価格(税込): 」表示→display:inline; 非表示→display:none; */ } #relation_3 .sale_price .title { display:none; /*「販売価格(税込): 」表示→display:inline; 非表示→display:none; */ } #relation_4 .sale_price .title { display:none; /*「販売価格(税込): 」表示→display:inline; 非表示→display:none; */ } /* 商品コメントの表示・非表示 */ #relation_1 .productContents .mini { display:block; /*商品コメント 表示→display:block; 非表示→display:none; */ } #relation_2 .productContents .mini { display:block; /*商品コメント 表示→display:block; 非表示→display:none; */ } #relation_3 .productContents .mini { display:block; /*商品コメント 表示→display:block; 非表示→display:none; */ } #relation_4 .productContents .mini { display:none; /*商品コメント 表示→display:block; 非表示→display:none; */ } /* 表示番号1 by jQuery.carouFredSel ----------------------------------------------- */ #relation_1 { width:100%; overflow:hidden; } #relation_1 #carousel_detailsonota div { text-align: center; width: 160px; float: left; position: relative; } #two_maincolumn_left #relation_1 #carousel_detailsonota div, #two_maincolumn_right #relation_1 #carousel_detailsonota div { width: 160px; } #one_maincolumn #relation_1 #carousel_detailsonota div, #one_maincolumn #relation_1 #carousel_detailsonota div { width: 156px; } #relation_1 #carousel_detailsonota div img { padding:3px; border:#CCC 1px solid; } #relation_1 #carousel_detailsonota div span { display: none; } #relation_1 #carousel_detailsonota div:hover span { background-color: #fff; border:1px solid #999; color: #333; font-size: 11px; display: inline-block; width: 90px; padding: 2px; margin: 0 0 0 -50px; position: absolute; top:5px; left: 50%; border-radius: 3px; } /***** 表示番号2 *****/ #relation_2 .product_item { float: left; width: 46%; margin-right:4%; } /* メインカラム用 2カラム時*/ #two_maincolumn_right #relation_2 .product_item .productImage, #two_maincolumn_left #relation_2 .product_item .productImage { float: left; width: 20%; } #two_maincolumn_right #relation_2 .productContents, #two_maincolumn_left #relation_2 .productContents { float: right; width: 75%; } /* メインカラム用 3カラム時*/ #three_maincolumn #relation_2 .product_item .productImage { float: left; width: 25%; } #three_maincolumn #relation_2 .productContents { float: right; width: 70%; } /***** 表示番号3 *****/ #relation_3 .product_item { float: left; width: 31%; margin-right:2%; } /* メインカラム用 2カラム時*/ #two_maincolumn_right #relation_3 .product_item .productImage, #two_maincolumn_left #relation_3 .product_item .productImage { float: left; width: 33%; } #two_maincolumn_right #relation_3 .productContents, #two_maincolumn_left #relation_3 .productContents { float: right; width: 65%; } /* メインカラム用 3カラム時*/ #three_maincolumn #relation_3 .product_item .productImage { float: left; width: 40%; } #three_maincolumn #relation_3 .productContents { float: right; width: 55%; } /***** 表示番号4 *****/ #relation_4 .product_item { float: left; width: 23%; margin-right:2%; } /* メインカラム用 2カラム時*/ #two_maincolumn_right #relation_4 .product_item .productImage, #two_maincolumn_left #relation_4 .product_item .productImage { float: left; width: 45%; } #two_maincolumn_right #relation_4 .productContents, #two_maincolumn_left #relation_4 .productContents { float: right; width: 53%; } /* メインカラム用 3カラム時*/ #three_maincolumn #relation_4 .product_item .productImage { float: left; width: 50%; } #three_maincolumn #relation_4 .productContents { float: right; width: 42%; }