TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-28-2007, 05:07 AM   #1 (permalink)
The Wanderer
 
Join Date: Sep 2007
Posts: 8
Thanks: 0
Tozzie is on a distinguished road
Default BreadCrumb Navigation

Hey again!

i was wondering if someone could help me out.
What i want to do, is use a breadcrumb style navigation script, what i want it to do it look at the url, and take certain things from it,
so if the link is this: index.php?page=tutorials&page=list&cat=photoshop
it would make "Site Name > Tutorials > Photoshop"

Thanks to anyone that can help! :D
Tozzie is offline  
Reply With Quote
Old 09-28-2007, 05:32 AM   #2 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

PHP Code:
$page $_GET['page'];
$cat $_GET['cat'];

echo 
$pagename ' > ' $page ' > ' $cat
Why do you have a page list after the page tutorial? It'll only confuse everything.. remove it =(
Tanax is offline  
Reply With Quote
Old 09-28-2007, 06:01 AM   #3 (permalink)
The Wanderer
 
Join Date: Sep 2007
Posts: 8
Thanks: 0
Tozzie is on a distinguished road
Default

thanks :) i can use that to start off,
lol it was just a typo, the 2nd page= is act= :)

thanks alot
Tozzie is offline  
Reply With Quote
Old 09-28-2007, 11:44 AM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I've had fun writing this function :) ! Works like a dream. Even adds in the links for you and best of all, it's all automatic. Don't forget to give TalkPHP.com a mention if you use it! Please.

PHP Code:
function get_crumbs($szSeperator ' > ')
{
    
preg_match_all('/[a-z0-9]+=+([a-z0-9]+)&?/i'$_SERVER['QUERY_STRING'], $aMatches);
    
    
$iCount 1;
    
    for(
$iIndex 0$iIndex count($aMatches[1]); $iIndex++)
    {
        
$szQuery =& $aMatches[0][$iIndex];
        
        if(
substr($szQuery, -1) == '&')
        {
            
$szQuery substr($szQuery0, -1);
        }
        
        
$aQuery = array();
        
$szItem =& $aMatches[1][$iIndex];
        
        for(
$iCycle 0$iCycle $iCount$iCycle++)
        {
            
$aQuery[] = $aMatches[0][$iCycle];
        }
        
        
$iCount++;
        
        
$szItem '<a href="?' implode('&amp;'$aQuery) . '">' ucwords(strtolower($szItem)) . '</a>';
    }
    
    return 
implode($szSeperator$aMatches[1]);
}

echo 
'<a href="page.php">TalkPHP.com</a> &gt; ' get_crumbs(); 
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.

Last edited by Wildhoney : 09-28-2007 at 12:36 PM.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 09-28-2007, 09:43 PM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Interesting function, Wildhoney, but sadly it won't cope (in terms of display order) if the key/value pairs come in a differently. E.g. ?act=list&cat=photoshop&page=tutorials rather than page, act, cat.
Salathe is offline  
Reply With Quote
Old 09-28-2007, 10:54 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Yep. I realise that. It's its only downfall really. However, for what he asked, it is perfect! The idea itself was flawed, not the code. As long as users don't go switching arguments then you're laughing.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 09-29-2007, 07:17 PM   #7 (permalink)
The Wanderer
 
Join Date: Sep 2007
Posts: 8
Thanks: 0
Tozzie is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Yep. I realise that. It's its only downfall really. However, for what he asked, it is perfect! The idea itself was flawed, not the code. As long as users don't go switching arguments then you're laughing.
:) thanks so much for that little script :D i will learn alot from it :p
Tozzie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:12 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design