2012年10月8日カテゴリー:未分類

EC-CUBE2.12:「商品詳細ページのサブ情報」の表示パターンを管理画面から変更する

管理画面>デザイン管理>PCに「おすすめ表示管理」ページを新規作成し、表示番号を選択することで、「商品詳細ページのサブ情報」の表示パターンを変更できるようにする。「1列」「2列横並び」「スライド」の3パターンから選択する。

▼ここでのカスタマイズファイルをすべてダウンロードできます。
必要な箇所だけコピーしてご利用ください。
他のカスタマイズも含まれている場合がありますので、ファイルの上書きは絶対におやめください。
こちらから(facebookユーザーのみ)

(1)データベースに新しいテーブルを作成する

 テーブル(mtb_detailsub_line)を作成する

【MySQL・PostgreSQL】
[php]
CREATE TABLE mtb_detailsub_line (
id smallint,
name text,
rank smallint NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
[/php]

 テーブル(mtb_detailsub_line)にデータを登録する。
[php]
INSERT INTO mtb_detailsub_line (id, name, rank) VALUES (1, ‘1’, 0);
INSERT INTO mtb_detailsub_line (id, name, rank) VALUES (2, ‘2’, 1);
INSERT INTO mtb_detailsub_line (id, name, rank) VALUES (3, ‘3’, 2)
[/php]

(2)データベース「dtb_baseinfo」テーブルにカラムを追加。(ここに表示番号が登録される)
[php]
ALTER TABLE dtb_baseinfo ADD detailsub_line smallint NOT NULL DEFAULT 3
[/php]

(3)管理画面用のページを新規作成

 ■html/admin/design/detailsub_line.php
[php]
init();
$objPage->process();
?>
[/php]

 ■data/class_extends/page_extends/admin/design/LC_Page_Admin_Detailsub_Line_Ex.php.php
[php]

[/php]

 ■data/class/pages/admin/design/LC_Page_Admin_Detailsub_Line.php
[php]
tpl_mainpage = ‘design/detailsub_line.tpl’;
$this->tpl_subno = ‘detailsub_line’;
$this->tpl_mainno = ‘design’;
$masterData = new SC_DB_MasterData_Ex();
$this->arrLine = $masterData->getMasterData(‘mtb_detailsub_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(“商品詳細ページサブ情報表示管理”, “detailsub_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;
}
}
?>
[/php]

 ■data/Smarty/templates/admin/design/detailsub_line.tpl
[php]

表示番号 background-color: ;” >
  • この内容で登録する
【表示番号 1】

縦1列で表示。

【表示番号 2】

縦2列で表示。 【表示番号 3】

スライド表示。

[/php]

 ■data/Smarty/templates/admin/design/subnavi.tpl←リンクを追加
[php]
 class=”on” id=”navi-design-detailsub_line”>⑥ ■html/user_data/packages/admin/css/admin_contents.css
1205行あたり 「デザイン管理」の箇所に追加
[php]
/*おすすめ表示管理・商品一覧ページ表示管理・商品詳細ページサブ情報表示管理*/
#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;
}
[/php]

 管理画面用のイメージを追加
■html/user_data/packages/admin/img/designフォルダを作成し、下記イメージを置く。
上から、201.png 202.png 203.png


(4)フロントページを作成する。

 jQuery caroufredselを利用する。
http://caroufredsel.frebsite.nl/

■html/js/jquery.caroufredsel(追加)

■data/Smarty/templates/default/site_frame.tpl
[php]


[/php]

 ■data/Smarty/templates/default/detail.tpl
の箇所を書き換える。

▼▼本サイトの「faceboxからcolorboxに変更」カスタマイズを行っている場合
[php]























③ ■html/user_data/packages/default/css/contents.css
「▼商品詳細」の部分の一番最後に追加する。
[css]

/* サブ情報
———————————————– */
/***** 共通 *****/
.sub_area .subphotoimg img {
padding:3px;
border:#CCC 1px solid;
}

/***** 表示番号1 *****/
#two_maincolumn_left div.subtext,
#two_maincolumn_right div.subtext {
width: 71%;
}
#two_maincolumn_left div.subphotoimg,
#two_maincolumn_right div.subphotoimg {
margin-right:17px;
}
#three_maincolumn div.subphotoimg {
margin-right:4px;
}

/***** 表示番号2 *****/
#two_maincolumn_left #detailsub_line2 div.subtext,
#two_maincolumn_right #detailsub_line2 div.subtext {
width: 60%;
}
#two_maincolumn_left #detailsub_line2 div.subphotoimg,
#two_maincolumn_right #detailsub_line2 div.subphotoimg {
width: 40%;
margin-right:0;
}
#three_maincolumn #detailsub_line2 div.subtext {
width: 50%;
}
#three_maincolumn #detailsub_line2 div.subphotoimg {
width: 50%;
margin-right:0;
}
#detailsub_line2 .sub_area {
width:47%;
float:left;
margin-right:3%;
}

/***** 表示番号3 *****/
#detailsub_3 table {
margin-top:0;
border-top: 1px solid #CCC;
border-bottom: 1px solid #CCC;
border-left:none;
border-right:none;
}
#detailsub_3 table td {
vertical-align:top;
border:none;
}
#detailsub_3 table td.image img {
padding:3px;
border:#CCC 1px solid;
}
#detailsub_3 #tabs_detailsub div {
width:760px; /*横幅を指定する必要有り*/
float: left;
overflow: hidden;
}
#three_maincolumn #detailsub_3 #tabs_detailsub div {
width:580px; /*横幅を指定する必要有り*/
}
#detailsub_3 #tabs_detailsub h3 {
line-height: 20px;
margin: 0 0 10px 0;
font-size:140%;
}
#detailsub_3 #pager_detailsub {
text-align: center;
}
#detailsub_3 #pager_detailsub a {
border: 1px solid transparent;
border-bottom: none;
border-left: none;
border-color: #ccc;
color: #999;
text-decoration: none;
display: inline-block;
padding: 10px 20px;
}
#detailsub_3 #pager_detailsub a:hover {
color: #666;
}
#detailsub_3 #pager_detailsub a:first-child {
border-left: 1px solid #ccc;
}
#detailsub_3 #pager_detailsub a.selected {
background-color: #F4F0EE;
color: #333;
}
[/css]

..