PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
gtowle
Forum Newbie
Posts: 2 Joined: Wed Jun 13, 2007 2:11 pm
Location: Santa Fe, NM
Post
by gtowle » Wed Jun 13, 2007 2:21 pm
I'm trying -unsuccessfully so far- to modify this function so that only the parent link shows in the navigation, rather than the parent AND the current page (as it now does).
Can someone offer some help? Thanks.
Code: Select all
function getCategoriesNavLine($parent=0, &$tree){
$l = $tree->collection[$parent]->level;
$pa = $tree->collection[$parent];
$nav = "";
for($i = $l; $i >= 1; $i--){
if(($i==0) || ($i>$l-4)){
$nav = '/ <a href="'.getCatalogUrl($pa->caption, $pa->id, 1).'">'.gs($pa->caption).'</a> '.($i<>$l?"":"").$nav;
}
else{
$nav = '.. / '.$nav;
}
if($i>0){
$pa = $tree->collection[$pa->parent_id];
}
}
return $nav;
}
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Wed Jun 13, 2007 2:47 pm
from what I see it shows:
Code: Select all
/root/../grandgrandparent/grandparent/parent/item
which one would you like to get rid of?
gtowle
Forum Newbie
Posts: 2 Joined: Wed Jun 13, 2007 2:11 pm
Location: Santa Fe, NM
Post
by gtowle » Thu Jun 14, 2007 1:03 am
Weirdan-
How do you interpret that???
I want to get rid of item, I believe (assuming that would be the "current" page ("page" for lack of better term).
Thanks.
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Fri Jun 15, 2007 1:17 pm
Code: Select all
function getCategoriesNavLineWithoutCurrentItem($parent=0, &$tree){
$parent = $tree->collection[$parent]->parent_id; // <====
$l = $tree->collection[$parent]->level;
$pa = $tree->collection[$parent];
$nav = "";
for($i = $l; $i >= 1; $i--){
if(($i==0) || ($i>$l-4)){
$nav = '/ <a href="'.getCatalogUrl($pa->caption, $pa->id, 1).'">'.gs($pa->caption).'</a> '.($i<>$l?"":"").$nav;
}
else{
$nav = '.. / '.$nav;
}
if($i>0){
$pa = $tree->collection[$pa->parent_id];
}
}
return $nav;
}