Page 1 of 1

Trying to modify a function.

Posted: Wed Jun 13, 2007 2:21 pm
by gtowle
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;
	}

Posted: Wed Jun 13, 2007 2:47 pm
by Weirdan
from what I see it shows:

Code: Select all

/root/../grandgrandparent/grandparent/parent/item
which one would you like to get rid of?

Posted: Thu Jun 14, 2007 1:03 am
by gtowle
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.

Posted: Fri Jun 15, 2007 1:17 pm
by Weirdan

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;
        }