[EC-CUBE]パンくずリスト設置

「[EC-CUBE]パンくずリスト設置」の編集履歴(バックアップ)一覧はこちら

[EC-CUBE]パンくずリスト設置」(2009/05/07 (木) 12:39:19) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

こんな感じでパンくずを表示させる。 画面イメージ /data/class_extends/helper_extends/SC_Helper_DB_EX.php functionを2つ追加。 #highlight(linenumber,php){{ <?php require_once(CLASS_PATH . "helper/SC_Helper_DB.php"); /** * DB関連のヘルパークラス(拡張). * * LC_Helper_DB をカスタマイズする場合はこのクラスを編集する. */ class SC_Helper_DB_Ex extends SC_Helper_DB { /** * 2009.05.07 パンくずリスト表示機能追加 **/ function sfGetTopicPath($category_id) { // 商品が属するカテゴリIDを縦に取得 $objQuery = new SC_Query(); $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); $TopicPath = " > "; // カテゴリー名称を取得 foreach($arrCatID as $key => $val){ $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; $arrVal = array($val); $CatName = $objQuery->getOne($sql, $arrVal); if($val != $category_id){ $TopicPath .= '<a href="./list.php?category_id =' .$val. '">'. $CatName . '</a> >'; } else { $TopicPath .= $CatName; } } return $TopicPath; } /** * 2009.05.07 パンくずリスト表示機能追加 **/ function sfGetTopicPath2($category_id) { // 商品が属するカテゴリIDを縦に取得 $objQuery = new SC_Query(); $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); $TopicPath = " > "; // カテゴリー名称を取得 foreach($arrCatID as $key => $val){ $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; $arrVal = array($val); $CatName = $objQuery->getOne($sql, $arrVal); $TopicPath .= '<a href="./list.php?category_id =' .$val. '">'. $CatName . '</a> >'; } return $TopicPath; } } ?> }} /data/class/pages/products/LC_Page_Products_List.php process()の中の// タイトル編集部分に以下を追加。 #highlight(linenumber,php){{ // タイトル編集 $tpl_subtitle = ""; if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; } elseif (empty($arrCategory_id[0])) { $tpl_subtitle = "全商品"; } else { $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; // 2009.05.07 @パンくずリスト設置機能追加 $TopicPath = $objDb->sfGetTopicPath($arrCategory_id[0]); $this->tpl_topicpath = $TopicPath; } }} /data/class/pages/products/LC_Page_Products_Detail.php process()の中に以下を追加。 #highlight(linenumber,php){{ // サブタイトルを取得 $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], $status); $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $this->tpl_subtitle = $arrFirstCat['name']; // 2009.05.07 @パンくずリスト表示機能追加 $arrTopicPath = $objDb->sfGetTopicPath2($arrCategory_id[0]); $this->tpl_topicpath = $arrTopicPath; // 関連カテゴリを取得 $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id); }} 最後に表示するテンプレート(この場合はメインテンプレート)に表示できるように記述。 /data/Smarty/templates/default/site_main.tpl #highlight(linenumber,php){{ <!--{* ▼HEADER *}--> <!--{if $arrPageLayout.header_chk != 2}--> <!--{include file= $header_tpl}--> <!--{/if}--> <!--{* ▲HEADER *}--> <!--{* ▼CONTENTS *}--> <div id="container"> <!--{* ▼パンくずリスト @2009.05.09追加 *}--> <!--{if $tpl_topicpath != ""}--> <a href="<!--{$smarty.const.SITE_URL}-->index.php">TopPage</a> <!--{$tpl_topicpath}--> <!--{$arrProduct.name|escape}--> <!--{/if}--> <!--{* ▲パンくずリスト *}--> }}
こんな感じでパンくずを表示させる。 画面イメージ &ref(a03.jpg) /data/class_extends/helper_extends/SC_Helper_DB_EX.php functionを2つ追加。 #highlight(linenumber,php){{ <?php require_once(CLASS_PATH . "helper/SC_Helper_DB.php"); /** * DB関連のヘルパークラス(拡張). * * LC_Helper_DB をカスタマイズする場合はこのクラスを編集する. */ class SC_Helper_DB_Ex extends SC_Helper_DB { /** * 2009.05.07 パンくずリスト表示機能追加 **/ function sfGetTopicPath($category_id) { // 商品が属するカテゴリIDを縦に取得 $objQuery = new SC_Query(); $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); $TopicPath = " > "; // カテゴリー名称を取得 foreach($arrCatID as $key => $val){ $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; $arrVal = array($val); $CatName = $objQuery->getOne($sql, $arrVal); if($val != $category_id){ $TopicPath .= '<a href="./list.php?category_id =' .$val. '">'. $CatName . '</a> >'; } else { $TopicPath .= $CatName; } } return $TopicPath; } /** * 2009.05.07 パンくずリスト表示機能追加 **/ function sfGetTopicPath2($category_id) { // 商品が属するカテゴリIDを縦に取得 $objQuery = new SC_Query(); $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); $TopicPath = " > "; // カテゴリー名称を取得 foreach($arrCatID as $key => $val){ $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; $arrVal = array($val); $CatName = $objQuery->getOne($sql, $arrVal); $TopicPath .= '<a href="./list.php?category_id =' .$val. '">'. $CatName . '</a> >'; } return $TopicPath; } } ?> }} /data/class/pages/products/LC_Page_Products_List.php process()の中の// タイトル編集部分に以下を追加。 #highlight(linenumber,php){{ // タイトル編集 $tpl_subtitle = ""; if ($_GET['mode'] == 'search') { $tpl_subtitle = "検索結果"; } elseif (empty($arrCategory_id[0])) { $tpl_subtitle = "全商品"; } else { $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $tpl_subtitle = $arrFirstCat['name']; // 2009.05.07 @パンくずリスト設置機能追加 $TopicPath = $objDb->sfGetTopicPath($arrCategory_id[0]); $this->tpl_topicpath = $TopicPath; } }} /data/class/pages/products/LC_Page_Products_Detail.php process()の中に以下を追加。 #highlight(linenumber,php){{ // サブタイトルを取得 $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], $status); $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); $this->tpl_subtitle = $arrFirstCat['name']; // 2009.05.07 @パンくずリスト表示機能追加 $arrTopicPath = $objDb->sfGetTopicPath2($arrCategory_id[0]); $this->tpl_topicpath = $arrTopicPath; // 関連カテゴリを取得 $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id); }} 最後に表示するテンプレート(この場合はメインテンプレート)に表示できるように記述。 /data/Smarty/templates/default/site_main.tpl #highlight(linenumber,php){{ <!--{* ▼HEADER *}--> <!--{if $arrPageLayout.header_chk != 2}--> <!--{include file= $header_tpl}--> <!--{/if}--> <!--{* ▲HEADER *}--> <!--{* ▼CONTENTS *}--> <div id="container"> <!--{* ▼パンくずリスト @2009.05.09追加 *}--> <!--{if $tpl_topicpath != ""}--> <a href="<!--{$smarty.const.SITE_URL}-->index.php">TopPage</a> <!--{$tpl_topicpath}--> <!--{$arrProduct.name|escape}--> <!--{/if}--> <!--{* ▲パンくずリスト *}--> }}

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。