Home > EC-CUBE > カスタマイズ Archive

カスタマイズ Archive

EC-CUBE 詳細ページ毎にキーワードを入れる

EC-CUBE 2.0.1

現段階では、[基本情報管理]→[SEO管理]の商品詳細ページ欄の[メタタグ:Description]や[メタタグ:Keywords]の欄に入力をすると、すべての詳細ページに同じ内容がはいってしまうので使えなかったが、EC-CUBE開発コミュニティのこのスレッドに解決策が投稿されていた。

/data/Smarty/templates/site_frame.tplの

<meta name="keywords" content="<!--{$arrPageLayout.keyword|escape}-->">

<meta name=”keywords” content=”<!–{$arrPageLayout.keyword|escape}–><!–{if $arrProduct.comment3}–>,<!–{$arrProduct.comment3|escape}–><!–{/if}–>“>

に入れ替えることでキーワードが個別に表示されるようになった。
Descriptionはまだうまくいっていないようですが・・・。

ECC-CUBE カテゴリ一覧に説明文を入れる

データベース(postgresql)の、テーブル dtb_category にフィールドを1つ追加

フィールド(カラム)名:description   型:text

■修正するファイル

data/Smarty/templates/default/admin/products/category.tpl
data/Smarty/templates/default/list.tpl
data/class/pages/admin/products/LC_Page_Admin_Products_Category.php
data/class/pages/products/LC_Page_Products_List.php
shop/user_data/css/common.css

■data/Smarty/templates/default/admin/products/category.tpl

113行目あたり

<td width=”428″ valign=”top”>

<span class=”red12″><!–{$arrErr.category_name}–></span>
●この行を変更 <input type=”text” name=”category_name” value=”<!–{$arrForm.category_name|escape}–>” size=”30″ class=”box30″ maxlength=”<!–{$smarty.const.STEXT_LEN}–>”/>
<input type=”submit” name=”button” value=”登録”/><span class=”red10″> (上限<!–{$smarty.const.STEXT_LEN}–>文字)</span>
<table width=”428″ border=”0″ cellspacing=”0″ cellpadding=”0″ summary=” “>
<tr><td height=”15″></td></tr>

次のように変更

<td width=”428″ valign=”top”>

<span class=”red12″><!–{$arrErr.category_name}–></span>
●この行を変更 <input type=”text” name=”category_name” value=”<!–{$arrForm.category_name|escape}–>” size=”30″ class=”box30″ maxlength=”<!–{$smarty.const.STEXT_LEN}–>”/><br/>
■この行を追加 <textarea name=”description” cols=80 rows=10><!–{$arrForm.description|escape}–></textarea><br/>
<input type=”submit” name=”button” value=”登録”/><span class=”red10″> (上限<!–{$smarty.const.STEXT_LEN}–>文字)</span>
<table width=”428″ border=”0″ cellspacing=”0″ cellpadding=”0″ summary=” “>
<tr><td height=”15″></td></tr>

■data/Smarty/templates/default/list.tpl

57行あたり

<input type=”hidden” name=”orderby” value=”<!–{$orderby}–>” />
<input type=”hidden” name=”product_id” value=”" />
<div id=”listtitle”><h2><!–★タイトル★–><!–{$tpl_subtitle}–></h2></div>
■この行を追加 <div id=”category_description”><!–{$arrSearch.description}–></div>
<!–検索条件ここから–>
<!–{if $tpl_subtitle == “検索結果”}–>
<ul class=”pagecondarea”>

■data/class/pages/admin/products/LC_Page_Admin_Products_Category.php

111行あたり

$oquery = new SC_Query();
$where = “category_id = ?”;
$cat_name = $oquery->get(“dtb_category”, “category_name”, $where, array($_POST['category_id']));
■この行を追加 $cat_desc = $oquery->get(“dtb_category”, “description”, $where, array($_POST['category_id']));
// 入力項目にカテゴリ名を入力する。
$this->arrForm['category_name'] = $cat_name;
■この行を追加 $this->arrForm['description'] = $cat_desc;
// POSTデータを引き継ぐ
$this->arrForm['category_id'] = $_POST['category_id'];
break;

223行あたり

// 入力データを渡す。
$sqlval = $this->objFormParam->getHashArray();
■この行を追加 GC_Utils_Ex::gfPrintLog($sqlval['category_name']);
■この行を追加 GC_Utils_Ex::gfPrintLog($sqlval['description']);
$sqlval['create_date'] = “Now()”;
$sqlval['update_date'] = “Now()”;
$sqlval['creator_id'] = $_SESSION['member_id'];

254行あたり

$parent_category_id = ’0′;
}

●この行を変更 $col = “category_id, category_name, level, rank”;
$where = “del_flg = 0 AND parent_category_id = ?”;
$objQuery->setoption(“ORDER BY rank DESC”);
$arrRet = $objQuery->select($col, “dtb_category”, $where, array($parent_category_id));

次のように変更

$parent_category_id = ’0′;
}

●この行を変更 $col = “category_id, category_name, description, level, rank”;
$where = “del_flg = 0 AND parent_category_id = ?”;
$objQuery->setoption(“ORDER BY rank DESC”);
$arrRet = $objQuery->select($col, “dtb_category”, $where, array($parent_category_id));

264行あたり

/* パラメータ情報の初期化 */
function lfInitParam() {
$this->objFormParam->addParam(“カテゴリ名”, “category_name”, STEXT_LEN, “KVa”, array(“EXIST_CHECK”,”SPTAB_CHECK”,”MAX_LENGTH_CHECK”));
■この行を追加 $this->objFormParam->addParam(“カテゴリ説明”, “description”, STEXT_LEN, “KVa”);
}

/* 入力内容のチェック */

■data/class/pages/products/LC_Page_Products_List.php

133行あたり

}else{
$arrCat = $conn->getOne(“SELECT category_name FROM dtb_category WHERE category_id = ?”, $arrCategory_id);
$arrSearch['category'] = $arrCat;
■この行を追加 $arrDesc = $conn->getOne(“SELECT description FROM dtb_category WHERE category_id = ?”, $arrCategory_id);
■この行を追加 $arrSearch['description'] = $arrDesc;
}

// 商品名検索条件

これは、EC-CUBE開発コミュニティの「カテゴリに説明を」 でktsさんの投稿で説明されている。

次に、カテゴリに説明を加えない場合には表示しないようにする設定をしておいた。

デザイン管理→ページ詳細設定→商品一覧ページ(data/Smarty/templates/default/list.tpl)

追加した行を if 文で表示・非表示にする

<!–{if $arrSearch.description != “”}–><!–●追加行●–>
<div id=”category_description”><!–{$arrSearch.description}–></div>
<!–{/if}–><!–●追加行●–>

あとはCSSで体裁を整える。

Home > EC-CUBE > カスタマイズ Archive

Return to page top