カテゴリーページにパンくずリストを表示する
1./data/class_extends/page_extends/products/LC_Page_Products_List_Ex.php
actionメソッドに、パンくずリストを出力するためのコードを追記します。
/**
* action
*/
function action() {
parent::action();
// パンくずタグ生成 下記を追記
$objDb = new SC_Helper_DB_Ex();
if ( $this->arrForm['category_id'] ) {
$arrCatId = $objDb->sfGetParents( "dtb_category", "parent_category_id", "category_id", $this->arrForm['category_id'] );
$TopicPath = '<a href="'.TOP_URLPATH.'">'.ホーム.'</a> > ';
foreach ( $arrCatId as $key => $val ) {
$arrCatName = $objDb->sfGetCat( $val );
if ( $val != $this->arrForm['category_id'] ) {
$TopicPath .= '<a href="'.TOP_URLPATH.'products/list.php?category_id='.$val.'">'.$arrCatName['name'].'</a> > ';
} else {
$TopicPath .= $arrCatName['name'];
}
}
} else {
$TopicPath = '<a href="'.TOP_URLPATH.'">'.ホーム.'</a> > '.$this->arrForm['name'].' の検索結果';
}
$this->TopicPath = $TopicPath;
}
2./data/Smarty/templates/テンプレート名/products/list.php
1で生成したパンくずリストは$TopicPathという変数に入っています。カテゴリーページ用のテンプレートにその変数を埋め込みます。適当な位置にいれちゃってください。
<div id="topicPath">
<p>
<!--{$TopicPath}-->
</p>
<!-- end #topicPath --></div>
商品詳細ページにパンくずリストを表示する
1./data/class_extends/page_extends/products/LC_Page_Products_Detail_Ex.php
カテゴリーページと同じように、actionメソッドに、パンくずリストを出力するためのコードを追記します。
/**
* action
*/
function action() {
parent::action();
// パンくずhtml生成
$objDb = new SC_Helper_DB_Ex();
$arrCategory_id = $objDb->sfGetCategoryId( $this->arrProduct['product_id'] );
$arrCatId = $objDb->sfGetParents( "dtb_category", "parent_category_id", "category_id", $arrCategory_id[0] );
$TopicPath = '<a href="'.TOP_URLPATH.'">'.ホーム.'</a> > ';
foreach ( $arrCatId as $key => $val ) {
$arrCatName = $objDb->sfGetCat( $val );
$TopicPath .= '<a href="'.TOP_URLPATH.'products/list.php?category_id='.$val.'">'.$arrCatName['name'].'</a>';
if ( $val != $arrCategory_id[0] ) {
$TopicPath .= ' > ';
}
}
$this->TopicPath = $TopicPath.' > '.$this->arrProduct['name'];
}
2./data/Smarty/templates/テンプレート名/products/detail.php
テンプレートの方もカテゴリーページと同じように$TopicPathにパンくずリストが入っているので適当な位置に追記します。
<div id="topicPath">
<p>
<!--{$TopicPath}-->
</p>
<!-- end #topicPath --></div>
これでカテゴリーページと、商品詳細ページにパンくずリストが表示されるようになります。その他のページはまだ未調査です…。分かり次第追記します。
