ソースそのものを以下のサイトを参考
www.gnnk.net
web book movie
[EC-CUBE]パンくずリスト
バージョンが古いのか、上記サイトの指示に従ってソースを埋めても動作しなかったので、以下覚書。
なお、以下の行数はEC CUBE version 2.3.4
/data/class_extends/helper_extends/SC_Helper_DB_Ex.php
37行目に以下を追加
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;
}
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
107行目に以下を追加
$TopicPath = $objDb->sfGetTopicPath($arrCategory_id[0]);
$this->tpl_topicpath = $TopicPath;
こちらは107行目ではなく113行目
/data/class/pages/products/LC_Page_Products_Detail.php
211行目に以下を追加
$arrTopicPath = $objDb->sfGetTopicPath2($arrCategory_id[0]);
$this->tpl_topicpath = $arrTopicPath;
これは211行目ではなく231行目
/data/Smarty/templates/default/site_main.tpl
37行目に以下を追加
<!–{if $tpl_topicpath != ""}–>
<a href="<!–{$smarty.const.SITE_URL}–>index.php">TopPage</a>
<!–{$tpl_topicpath}–>
<!–{$arrProduct.name|escape}–>
<!–{/if}–>
これは、設置した場所であれば、指定以外(detail.phpやlist.php)でも可。
ただし、URLを静的化している場合でも、発行されるURLは動的(list.php?category=***の形)になる。