For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > September 2006 > Help me finish this...Please!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help me finish this...Please!
Simon Harris

2006-09-06, 9:57 pm

Hi All,

I've very nearly finished my bread crumb trail script. It picks up the URL,
and then turns it into a bread crumb trail, so the user can always walk back
to where they came from.

I have two problems, which I am struggling with:

1) If the URL is, for example /attractions/Dorset then the trail ens up like
this: 'attractions'. Only when I add a trailing / to the URL does the trail
end up as it should be: 'attractions > Dorset'

2) I always seem to end up with a trailing > sign

My code is below - Any help getting this finished would be appreciated.

Thanks!
Simon.


// Generate Bread Crumb Trail
function genbctrail() {
$arr_bits = explode("/",$_SERVER{'REQUEST_URI'});
$count = count($arr_bits);

for ($i=0; $i < $count-1; $i++) {

$StrHref = $StrHref. $arr_bits[$i]. "/";
$StrLink = "<a href=" .$StrHref. ">" .urldecode($arr_bits[$i]). "</a>";

$countForCompare = $count-1;

// Diags: print $i. " - " .$countForCompare. "<br>";

if ($i > 0 && $i <= $countForCompare) {
// print $i. " - " .$count. "<br>";
$StrLink = $StrLink. " &gt; ";
}

$StrBCTrail = $StrBCTrail. $StrLink;
}
print $StrBCTrail;

}



--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!


--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 9127 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!


Simon Harris

2006-09-06, 9:57 pm

I've just solved the second problem with the trailing &gt; sign, here is my
updated code:


// Generate Bread Crumb Trail
function genbctrail() {
$arr_bits = explode("/",$_SERVER{'REQUEST_URI'});
$count = count($arr_bits);
$countForCompare = $count-2;

for ($i=0; $i < $count-1; $i++) {

$StrHref = $StrHref. $arr_bits[$i]. "/";
$StrLink = "<a href=" .$StrHref. ">" .urldecode($arr_bits[$i]). "</a>";

if (($i > 0) && ($i <> $countForCompare)) {
$StrLink = $StrLink. " &gt; ";
}

$StrBCTrail = $StrBCTrail. $StrLink;
}
print $StrBCTrail;
}

Would appreciate any ideas or pointers on the first problem.

Regards,
Simon.


--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 9127 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com