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

こんな感じでパンくずを表示させる。

画面イメージ

/data/class_extends/helper_extends/SC_Helper_DB_EX.php
functionを2つ追加。

  1. <?php
  2. require_once(CLASS_PATH . "helper/SC_Helper_DB.php");
  3.  
  4. /**
  5.  * DB関連のヘルパークラス(拡張).
  6.  *
  7.  * LC_Helper_DB をカスタマイズする場合はこのクラスを編集する.
  8.  */
  9. class SC_Helper_DB_Ex extends SC_Helper_DB {
  10.  
  11. /**
  12. * 2009.05.07 パンくずリスト表示機能追加
  13. **/
  14. function sfGetTopicPath($category_id) {
  15. // 商品が属するカテゴリIDを縦に取得
  16. $objQuery = new SC_Query();
  17. $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
  18. $TopicPath = " > ";
  19.  
  20. // カテゴリー名称を取得
  21. foreach($arrCatID as $key => $val){
  22. $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
  23. $arrVal = array($val);
  24. $CatName = $objQuery->getOne($sql, $arrVal);
  25. if($val != $category_id){
  26. $TopicPath .= '<a href="./list.php?category_id =' .$val. '">'. $CatName . '</a> >';
  27. } else {
  28. $TopicPath .= $CatName;
  29. }
  30. }
  31. return $TopicPath;
  32. }
  33.  
  34. /**
  35. * 2009.05.07 パンくずリスト表示機能追加
  36. **/
  37. function sfGetTopicPath2($category_id) {
  38. // 商品が属するカテゴリIDを縦に取得
  39. $objQuery = new SC_Query();
  40. $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id);
  41. $TopicPath = " > ";
  42. // カテゴリー名称を取得
  43. foreach($arrCatID as $key => $val){
  44. $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?";
  45. $arrVal = array($val);
  46. $CatName = $objQuery->getOne($sql, $arrVal);
  47. $TopicPath .= '<a href="./list.php?category_id =' .$val. '">'. $CatName . '</a> >';
  48. }
  49. return $TopicPath;
  50. }
  51. }
  52. ?>
  53.  

/data/class/pages/products/LC_Page_Products_List.php
process()の中の// タイトル編集部分に以下を追加。
  1. // タイトル編集
  2. $tpl_subtitle = "";
  3. if ($_GET['mode'] == 'search') {
  4. $tpl_subtitle = "検索結果";
  5. } elseif (empty($arrCategory_id[0])) {
  6. $tpl_subtitle = "全商品";
  7. } else {
  8. $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
  9. $tpl_subtitle = $arrFirstCat['name'];
  10.  
  11. // 2009.05.07 @パンくずリスト設置機能追加
  12. $TopicPath = $objDb->sfGetTopicPath($arrCategory_id[0]);
  13. $this->tpl_topicpath = $TopicPath;
  14. }
  15.  

/data/class/pages/products/LC_Page_Products_Detail.php
process()の中に以下を追加。
  1. // サブタイトルを取得
  2. $arrCategory_id = $objDb->sfGetCategoryId($arrRet[0]['product_id'], $status);
  3. $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]);
  4. $this->tpl_subtitle = $arrFirstCat['name'];
  5.  
  6. // 2009.05.07 @パンくずリスト表示機能追加
  7. $arrTopicPath = $objDb->sfGetTopicPath2($arrCategory_id[0]);
  8. $this->tpl_topicpath = $arrTopicPath;
  9.  
  10. // 関連カテゴリを取得
  11. $this->arrRelativeCat = $objDb->sfGetMultiCatTree($tmp_id);
  12.  

最後に表示するテンプレート(この場合はメインテンプレート)に表示できるように記述。
/data/Smarty/templates/default/site_main.tpl
  1. <!--{*HEADER *}-->
  2. <!--{if $arrPageLayout.header_chk != 2}-->
  3. <!--{include file= $header_tpl}-->
  4. <!--{/if}-->
  5. <!--{*HEADER *}-->
  6.  
  7. <!--{* ▼CONTENTS *}-->
  8. <div id="container">
  9.  
  10. <!--{* ▼パンくずリスト @2009.05.09追加 *}-->
  11. <!--{if $tpl_topicpath != ""}-->
  12. <a href="<!--{$smarty.const.SITE_URL}-->index.php">TopPage</a>
  13. <!--{$tpl_topicpath}-->
  14. <!--{$arrProduct.name|escape}-->
  15. <!--{/if}-->
  16. <!--{* ▲パンくずリスト *}-->
  17.  
最終更新:2009年05月07日 12:39
ツールボックス

下から選んでください:

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