| 
	
 | 
 Posted by Justin Koivisto on 05/16/05 18:18 
petermichaux@yahoo.com wrote: 
 
> Ahh. Multiple browsers. 
>  
> Perhaps I could write the series of categoryID used to get to the 
> current category directly in the web page. Somehow this would be 
> invisible to the user. Then when they click a new link their browser 
> sends me this series and I can append to it. This is a job for 
> javascript? And if they press the back button then the page they go 
> back to will have the correct series for that page. Sound good? 
>  
 
If I am using some kind of breadcrumb, I tend to take the easy route: 
 
Say I was viewing Truck tires (as in your previous example), my URI 
would look like this: 
 
/automotive/tires/truck/ 
 
Then for the breadcrumb, I'll just do something similar to: 
 
<?php 
$tmp=explode('/',$_SERVER['REQUEST_URI']); 
$num_levels=count($tmp); 
$nav=array(); 
for($i=$num_levels-1;$i>0;$i--){ 
    if(empty($tmp[$i])){ 
        // in case there were two slashes together 
        // in the URI, or if it ended with a slash. 
        // **this will not add the top level link "/" 
        array_pop($tmp); 
        continue; 
    }else{ 
        // if URI started with a slash, then the first 
        // element will be empty, leaving us with the 
        // leading slash. 
        $nav[]='<a href="'.join('/',$tmp).'/">'. 
            ucwords($tmp[$i]).'</a>'; 
        array_pop($tmp); 
    } 
} 
$nav=array_reverse($nav); 
echo join(" » ",$nav); 
?> 
 
--  
Justin Koivisto - justin@koivi.com 
http://koivi.com
 
  
Navigation:
[Reply to this message] 
 |