バージョン選択

フォーラム

メニュー

オンライン状況

58 人のユーザが現在オンラインです。 (54 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 58
もっと...

サイト内検索

その他 > その他 > パンくずリストの表示

その他

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
ゲスト
投稿日時: 2007/8/15 1:07
対応状況: −−−
Re: パンくずリストの表示
再三アドバイスいただきまして本当にありがとうございます。
ご提示された通りに /products/detail.php に追記してみたところ、見事に完動いたしました。
私事ですが、これの実現を目指して1週間ほど試行錯誤していましたので大変嬉しい限りです。重ねてお礼を申し上げます。
今後は「何故、この順番だと動くのか?」を理解できるようになるため PHP の勉強をしたいと思います。

なおこのスレッドを立てた方の目標は、より深い階層までのパンくずリスト実現のようですので、対応状況を勝手に「解決済」にしないでおきます。
ゲスト
投稿日時: 2007/8/17 2:31
対応状況: −−−
Re: パンくずリストの表示
初心者でわからないのですが
**********************
商品詳細ページに

<!--{$category_name}-->
**********************
とございますが
商品詳細ページとかいてありますが
user_data / templates / detail.tpl
のファイルの表示したいところに
下記を入れればよろしいいのでしょうか?

***************************************
<a href="<!--{$smarty.const.SITE_URL}-->">HOME</a>
<!--{if $arrProduct.root_category_id != $arrProduct.parent_category_id}-->
> <a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrProduct.root_category_id}-->"><!--{$root_category_name}--></a>
<!--{/if}-->
<!--{if $arrProduct.parent_category_id != $arrProduct.category_id}-->
> <a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrProduct.parent_category_id}-->"><!--{$parent_category_name}--></a>
<!--{/if}-->
> <a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrProduct.category_id}-->"><!--{$category_name}--></a>
> <!--{$arrProduct.name|escape}-->

NSX
投稿日時: 2007/8/17 10:20
対応状況: −−−
常連
登録日: 2007/7/31
居住地:
投稿: 61
Re: パンくずリストの表示
無事表示されました!
どうもありがとうございます。

user_data / templates / detail.tpl

<H2></H2>
のすぐ下に記入すると表示できますよ。
がんばってくださいね。
NSX
投稿日時: 2007/8/17 10:27
対応状況: −−−
常連
登録日: 2007/7/31
居住地:
投稿: 61
Re: パンくずリストの表示
どうもありがとうございます。
無事表示できました。

しかし、今のまでは商品を選択したときしかパンくずリストが表示できないので、カテゴリーを選んだ時でも表示するようにしたいのですが、

html/user_data/templates/list.tpl


<a href="<!--{$smarty.const.SITE_URL}-->">HOME</a>
<!--{if $arrProduct.root_category_id != $arrProduct.parent_category_id}-->
> <a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrProduct.root_category_id}-->"><!--{$root_category_name}--></a>
<!--{/if}-->
<!--{if $arrProduct.parent_category_id != $arrProduct.category_id}-->
> <a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrProduct.parent_category_id}-->"><!--{$parent_category_name}--></a>
<!--{/if}-->
> <a href="<!--{$smarty.const.URL_DIR}-->products/list.php?category_id=<!--{$arrProduct.category_id}-->"><!--{$category_name}--></a>
> <!--{$arrProduct.name|escape}-->

を記入したんですが、HOME>>しか表示されませんでした。

lsit.phpもやはり触るでしょうか?

できましたら、リスト表示時もパンくずリストを表示したいのでよろしくお願いします。

現在はこんな感じです。
http://usmc.jp/
ryo
投稿日時: 2007/8/17 11:51
対応状況: −−−
一人前
登録日: 2007/7/26
居住地: 関西
投稿: 86
Re: パンくずリストの表示
僕は「親カテゴリを表示」を利用して、親の親を取得するように設定し、

top > root > 親の親 > 親 > 現在

と4階層まで対応しています。
かなり強引なんですけどね・・・

listとdetailの両方でパンくずの表示に成功してます。
強引すぎてここでソース晒すの恥ずかしいので止めと来ます(笑)

やろうと思えば最大の5階層まで対応できると思いますが、現在作成中のサイトでは必要ないので4階層で止めてます。


----------------
/* Ryo from KANSAI */
まいどっ!

NSX
投稿日時: 2007/8/17 12:35
対応状況: −−−
常連
登録日: 2007/7/31
居住地:
投稿: 61
Re: パンくずリストの表示
ryoさん

こんにちは!
listも表示できているんですね!

>強引すぎてここでソース晒すの恥ずかしいので止めと来ます(笑)

そんな事おっしゃらずに是非とも、ソースを見せていただけませんでしょうか?

どうぞよろしくお願いしますm(_ _)m
ryo
投稿日時: 2007/8/17 13:26
対応状況: −−−
一人前
登録日: 2007/7/26
居住地: 関西
投稿: 86
Re: パンくずリストの表示
随分いじったので、元からどこを変えたのかちょっと忘れたのですが、恐らく以下の方法だと思います。(本当に恥ずかしいくらい稚拙なソースですが)

まず、/html/products/list.phpの140行目あたりに以下の文を入れてます。(はっきりいって場所はどこでもいいはずです。)

引用:

// パンくずリスト用値取得(かなり強引。4階層まで対応)
// 親カテゴリID取得

$objPage->arrProduct["parent_category_id"] =
lfGetParentCategoryID($category_id);
// 今取得した親カテゴリの親カテゴリIDを取得
$objPage->arrProduct["grandparent_category_id"] =
lfGetParentCategoryID($objPage->arrProduct["parent_category_id"]);
// ルートカテゴリIDを取得
$objPage->arrProduct["root_category_id"] =
lfGetRootCategoryID($category_id);

// ルートカテゴリ名を取得
$objPage->arrProduct["root_category_name"] =
$conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($objPage->arrProduct["root_category_id"]));
// 親の親のカテゴリ名を取得
$objPage->arrProduct["grandparent_category_name"] =
$conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($objPage->arrProduct["grandparent_category_id"]));
// 親カテゴリ名を取得
$objPage->arrProduct["parent_category_name"] =
$conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($objPage->arrProduct["parent_category_id"]));
// 現在のカテゴリ名を取得
$objPage->arrProduct["current_category_name"] =
$conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id));


そのphpの最後の方の関数群に以下の関数を追加
引用:

/* 親カテゴリの取得 */
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;
}


後は、/html/user_data/templates/list.tplのパンくずリストを表示したい場所に以下を追加します。
(ココが最強に強引。もっとシンプルに記述できるかも?)

引用:

<!--{*パンくずリスト開始*}-->
<div id="pankuzu">
<a href="<!--{$smarty.const.SITE_URL}-->">TOP</a> >

<!--{if $category_id == $arrProduct.parent_category_id && $arrProduct.parent_category_id == $arrProduct.grandparent_category_id && $category_id == $arrProduct.root_category_id}-->
<!--{elseif $category_id != $arrProduct.parent_category_id && $arrProduct.parent_category_id == $arrProduct.grandparent_category_id && $arrProduct.grandparent_category_id == $arrProduct.root_category_id}-->
<a href="<!--{$smarty.const.SITE_URL}-->products/list.php?category_id=
<!--{$arrProduct.root_category_id}-->">
<!--{$arrProduct.root_category_name}--></a> >

<!--{elseif $category_id != $arrProduct.parent_category_id && $arrProduct.parent_category_id != $arrProduct.grandparent_category_id && $arrProduct.grandparent_category_id == $arrProduct.root_category_id}-->
<a href="<!--{$smarty.const.SITE_URL}-->products/list.php?category_id=
<!--{$arrProduct.root_category_id}-->">
<!--{$arrProduct.root_category_name}--></a> >
<a href="<!--{$smarty.const.SITE_URL}-->products/list.php?category_id=
<!--{$arrProduct.parent_category_id}-->">
<!--{$arrProduct.parent_category_name}--></a> >

<!--{else}-->
<a href="<!--{$smarty.const.SITE_URL}-->products/list.php?category_id=
<!--{$arrProduct.root_category_id}-->">
<!--{$arrProduct.root_category_name}--></a> >
<a href="<!--{$smarty.const.SITE_URL}-->products/list.php?category_id=
<!--{$arrProduct.grandparent_category_id}-->">
<!--{$arrProduct.grandparent_category_name}--></a> >
<a href="<!--{$smarty.const.SITE_URL}-->products/list.php?category_id=
<!--{$arrProduct.parent_category_id}-->">
<!--{$arrProduct.parent_category_name}--></a> >

<!--{/if}-->
// 以下は検索の場合、「検索結果」というタイトルの代わりに検索文字列でパンくずリストを作るための処理です。
必要な場合記述。必要なければcategory_nameだけでいいかも。

<!--{if $tpl_subtitle == "検索結果"}-->
<!--{$arrSearch.name|escape}-->
<!--{else}-->
<!--{$arrProduct.current_category_name}-->
<!--{/if}-->
</div>
<!--{*パンくずリスト終了*}-->

青字・・・コメント
黒字・・・PHPスクリプト
緑字・・・HTML表示部分


これでOKだと思うんですが、ダメだったらごめんなさい。
他にもいじってるところがあるんだと思いますw

同じように親の親の親の・・・とすればもう1階層増やすことも恐らく可能でしょう。


----------------
/* Ryo from KANSAI */
まいどっ!

NSX
投稿日時: 2007/8/17 13:57
対応状況: −−−
常連
登録日: 2007/7/31
居住地:
投稿: 61
Re: パンくずリストの表示
ryoさん

こんにちは、どうもありがとうございます。

長いソースをコピーしたりして、お手間を取らせてしまいました。

それでは早速チャレンジしますね。
NSX
投稿日時: 2007/8/17 14:16
対応状況: −−−
常連
登録日: 2007/7/31
居住地:
投稿: 61
Re: パンくずリストの表示
こんにちは!

早速ソースの追加しましたが、、
残念です、TOP>>とは出るのですが、後ろが表示されませんでした。

http://usmc.jp/
のような状態です。

どうもありがとうございました。

できれば、他触った箇所などは覚えてないですかネ。^_^;

ryo
投稿日時: 2007/8/17 19:28
対応状況: −−−
一人前
登録日: 2007/7/26
居住地: 関西
投稿: 86
Re: パンくずリストの表示
あれま、ダメでしたか

表示が出来ていないと言うことは、値の取得が出来ていないと思うので、tpl側ではなくphp側の問題だと思います。

ちなみに、どこまで取得できていないのでしょうか?
引用:
$objPage->arrProduct["parent_category_id"] = lfGetParentCategoryID($category_id);

この辺のIDから取得できていないのか、
引用:
$objPage->arrProduct["root_category_name"] =
$conn->getOne("SELECT category_name FROM dtb_category WHERE category_id =
?",array($objPage->arrProduct["root_category_id"]));

この辺の名前の取得が出来ていないのか。
(まぁ、カテゴリ名が表示されていない時点で、こちらは取得できていないけど・・・)

一度、tpl側で
引用:
<!--{$category_id}-->


引用:
<!--{$arrProduct.parent_category_id}-->


引用:
<!--{$arrProduct.grandparent_category_id}-->


引用:
<!--{$arrProduct.root_category_id}-->

の値を表示してみて、カテゴリIDが表示されているかどうか確認してみてください。
IDが取得できているのなら、その後の名前の取得で失敗していると思うので。


----------------
/* Ryo from KANSAI */
まいどっ!

« 1 (2) 3 »
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は89,036名です
総投稿数は110,020件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2314
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1296
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.