[Tutor] Automated Breadcrumb -- help for a PHP user

Chris Heisel chris at heisel.org
Tue Nov 25 15:55:32 EST 2003


Hi,

I'm a n00b to python coming from PHP land.

I'd like to create an automated breadcrumb script that would inspect the 
URL and create an appropriate bread crumb navigation set.

In PHP I'd so something like
function makeBread($url) {
     $path_parts = explode('/', $url);
     echo('<p class="trail">');
     foreach ($path_parts as $key => $value) {
         $where_at = $where_at + $value;
         echo('<a href="$where_at">'.$where_at.'</a>');
     }
}

I'd put this function in an external file include() it and make a call with:
<?php
makeBread($PHP_SELF)
?>
(Disclaimer: this code is really ugly its just an example...)

I'd like to do this in Python and make it a cgi-bin file so I could have 
something like this:
<!--#include virtual="/cgi-bin/bread.py" -->

But I'm not sure where to start. How can I pass the URL of the page 
making the include call to the script?

One its there I'm sure I can muddle through some flow control structures 
and what not to massage the URL into the various breadcrumb pieces...

Any help would be greatly appreciated.

Thanks in advance,

Chris





More information about the Tutor mailing list