2007年05月10日

商品詳細にパンくずリスト


[ EC-CUBEっぽいの ]

ずっとブロックで作ろうと考えていた「パンくずリスト」。。そんな面倒なことをするよりも、単純に各商品の商品詳細ページで表示してあげたほうが分かりやすいのかもしれない。。

\html\products\detail.php

// パンくずリスト用
$objPage->arrProduct["parent_category_id"] = lfGetParentCategoryID($objPage->arrProduct["category_id"]);
$objPage->arrProduct["root_category_id"] = lfGetRootCategoryID($objPage->arrProduct["category_id"]);

$objPage->category_id = sfGetCategoryId($tmp_id, "");
$objPage->category_name = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($objPage->category_id));

$objPage->parent_category_id = lfGetParentCategoryID($objPage->arrProduct["category_id"]);
$objPage->parent_category_name = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($objPage->parent_category_id));

$objPage->root_category_id = lfGetRootCategoryID($objPage->arrProduct["category_id"]);
$objPage->root_category_name = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($objPage->root_category_id));
/* 親カテゴリの取得 */
function lfGetParentCategoryID($category_id) {
$objQuery = new SC_Query();
$parent_category_id = $objQuery->get("dtb_category", "parent_category_id", "category_id = ?", array($category_id));
if($parent_category_id < 1) {
return $category_id;
}
return $parent_category_id;
}

/* ルートカテゴリの取得 */
function lfGetRootCategoryID($category_id) {
$objQuery = new SC_Query();
do{
$parent_category_id = $objQuery->get("dtb_category", "parent_category_id", "category_id = ?", array($category_id));
if($parent_category_id > 0) {
$category_id = $parent_category_id;
}
}while($parent_category_id > 1);
return $category_id;
}


テンプレートの適当な場所に追加

<div class="fs14">
<a href="<!--{$smarty.const.SITE_URL}-->">HOME</a>
<!--{if $arrProduct.root_category_id != $arrProduct.parent_category_id}-->
≫<a href="<!--{$smarty.const.URL_DIR}-->products/category_<!--{$arrProduct.root_category_id}-->.html" title="<!--{$root_category_name}-->"><!--{$root_category_name}--></a>
<!--{/if}-->
<!--{if $arrProduct.parent_category_id != $arrProduct.category_id}-->
≫<a href="<!--{$smarty.const.URL_DIR}-->products/category_<!--{$arrProduct.parent_category_id}-->.html" title="<!--{$root_category_name}-->@<!--{$parent_category_name}-->"><!--{$parent_category_name}--></a>
<!--{/if}-->
≫<a href="<!--{$smarty.const.URL_DIR}-->products/category_<!--{$arrProduct.category_id}-->.html" title="<!--{$root_category_name}-->@<!--{$parent_category_name}-->@<!--{$category_name}-->"><!--{$category_name}--></a>
</div>

まぁ。。。覚書程度

安全保安用品通販-安全コム

投稿者 こてつ : 2007年05月10日 14:09 | トラックバック
ブックマーク :

はてなブックマークに登録 livedoorクリップに登録 Buzzurlに登録 Yahoo!ブックマークに登録 users

最近の検索テーマ - 旬?!ワード
追伸  悪性リンパ腫  ヌレンザ  バリカー  undisclosed-recipients  かっけ  症状  outlook  ボラード  交換  脊椎反射  悪性リンパ腫とは  婚姻届受理証明書  構文チェック  outlook2003  ドアノブ  移行  改造  慶事用切手  RAZO  html  ラバーポール  ケンドル  リンパ腫  MRI 
[PR] 
[PR] 
トラックバック
このエントリーのトラックバックURL:
(このブログへの記事紹介・リンクがない場合トラックバックできません。)
http://good-match.net/mt/mt-5t5b5.cgi/1209

コメントしてください




保存しますか?