2012-03-06

ECCUBE 2.11用にパンくずリストを設定してみる。

ECCUBEのVer.2.11への移行の際、「パンくずリスト」も上手く移行できなかった。
以下、その時の手順です。

【手順】

1) ./data/class/pages/products/LC_Page_Products_List.php の編集

■ action() 内の末尾に、以下の「パンくずリストを取得」のコードを記述

    /**
     * Page のAction.
     *
     * @return void
     */
    function action() {
      ・
      ・
    //パンくずリストを取得
    $this->arrTopicPath = $this->lfTopicPath($this->mode, $this->arrForm['category_id'], $this->arrForm['name']);
    }

■ LC_Page_Products_List クラス内の末尾に、以下の「パンくずリストを設定」のコードを記述

/**
 * 商品一覧 のページクラス.
 *
 * @package Page
 * @author LOCKON CO.,LTD.
 * @version $Id: LC_Page_Products_List.php 21265 2011-09-29 09:50:08Z nanasess $
 */
class LC_Page_Products_List extends LC_Page_Ex {
      ・
      ・
      /**
      * パンくずリストを設定
      *
      * @return array
      */
    function lfTopicPath($mode, $category_id, $category_name){
        if ($mode == 'search') {
          $arrRet = $category_name . " の検索結果";
        } elseif (empty($category_id)){
          $arrRet = "全商品";
        } else {
          $objDb = new SC_Helper_DB_Ex();
          $arrCatId = $objDb->sfGetParents("dtb_category", "parent_category_id", "category_id", $category_id);
          foreach($arrCatId as $key => $val){
            $arrCatName = $objDb->sfGetCat($val);
            if($val != $category_id){
              $arrRet[] = '<a href="./list.php?category_id=' .$val. '">'. $arrCatName['name'] . '</a> > ';
            } else {
              $arrRet[] = $arrCatName['name'];
            }
          }
        }
        return $arrRet;
    }
}


2) ./data/class/pages/products/LC_Page_Products_Detail.php の編集

■ action() 内の末尾に、以下の「パンくずリストを取得」のコードを記述

    /**
    * Page のAction.
    *
    * @return void
    */
    function action() {
      ・
      ・
    // パンくずリストを取得
    $this->arrTopicPath = $this->lfTopicPath2($product_id);
    }

■ LC_Page_Products_Detail クラス内の末尾に、以下の「パンくずリストを設定」のコードを記述
/**
* 商品詳細 のページクラス.
*
* @package Page
* @author LOCKON CO.,LTD.
* @version $Id:LC_Page_Products_Detail.php 15532 2007-08-31 14:39:46Z nanasess $
*/
class LC_Page_Products_Detail extends LC_Page_Ex {
      ・
      ・
      /*
      * パンくずリストを設定
      * @return array
      */
    function lfTopicPath2($product_id){
        $objDb = new SC_Helper_DB_Ex();
        $arrCategory_id = $objDb->sfGetCategoryId($product_id);
        $arrCatId = $objDb->sfGetParents("dtb_category", "parent_category_id", "category_id", $arrCategory_id[0]);
        foreach($arrCatId as $key => $val){
          $arrCatName = $objDb->sfGetCat($val);
          $arrRet[] = '<a href="./list.php?category_id=' .$val. '">'. $arrCatName['name'] . '</a> > ';
        }
        $arrRet[] = $this->arrProduct['name'];
        return $arrRet;
    }
}


3) パンくずを表示させたい場所の.tplファイルに以下のコードを挿入

<!--{* ▼TOPIC PATH *}-->
<div id="topicpath">
<!--{if $smarty.server.PHP_SELF != '/index.php'}-->
  <p><a href="<!--{$smarty.const.HTTP_URL}-->">TopPage</a> >
  <!--{if $arrTopicPath}-->
    <!--{foreach from=$arrTopicPath item=Topic}-->
      <!--{$Topic}-->
    <!--{/foreach}-->
  <!--{else}--><!--{$tpl_title|h}-->
  <!--{/if}-->
  </p>
<!--{/if}-->
<!--{* ▲TOPIC PATH *}-->

0 件のコメント:

コメントを投稿