Creating a breadcrumb trail, without folders!

Discussion in 'PHP' started by billybrag, Oct 3, 2006.

  1. #1
    Hello all,

    I have a shop with categeories sub categories and products and i wondered if anyone had any ideas how i could go about creating a breadcrumb trail based on this and not using the only method i can find online, which is using the folder structure.

    Does anyone have any tutorials or know of any sites that could help?

    thanks all :)
     
    billybrag, Oct 3, 2006 IP
  2. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #2
    look into mod_rewrite, it will have exactly what you need.
     
    ServerUnion, Oct 3, 2006 IP
  3. billybrag

    billybrag Peon

    Messages:
    324
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hmm, thanks for the suggestion, but im on a windows server :(
     
    billybrag, Oct 3, 2006 IP
  4. ServerUnion

    ServerUnion Peon

    Messages:
    3,611
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There are ASAPI filters that will do it also, not sure of the name though, sorry...
     
    ServerUnion, Oct 3, 2006 IP
  5. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Working on the same problem on a WAMP installation -- Windows-Apache-MySql-PHP/Perl -- I came up with the following breadcrumb script in PHP:

    
    $server = $_SERVER["SERVER_NAME"];
    $originalpath = $_SERVER["PHP_SELF"];
    $urlbase = "http://".$server;
    
    $roottitle = "Home";
    $seperator = " > ";
    $ignore = "Home";
    
    $path = explode ("/", $originalpath);
    $totalelements = count ($path);
    printf("<a href=\"%s\">%s</a>", $urlbase, $roottitle);
    for($number=1; $number<$totalelements ; $number++)
    	{
    	$urlbase = $urlbase . "/" . $path[$number];
    	$path[$number] = str_replace("___", "_&_", $path[$number]);
    	$path[$number] = str_replace("_", " ", $path[$number]);
    	$path[$number] = str_replace("~", "?", $path[$number]);
    	$path[$number] = str_replace(".php", "", $path[$number]);
    	$path[$number] = ucwords($path[$number]);
    	if ($path[$number] != $ignore)
    		{
    		printf("%s<a href=\"%s\">%s</a>", $seperator, $urlbase, $path[$number]);
    		}
    	}
    
    Code (markup):
     
    clancey, Oct 3, 2006 IP