Breadcrumbs - not using folders

Discussion in 'PHP' started by PoPSiCLe, May 20, 2009.

  1. #1
    Hi.

    I'm trying to get my head around how to make a breadcrumb trail on a webpage. The webpage might or might not run on Apache, so mod_rewrite isn't an option for getting urls to turn into virtual folders.

    What I have is a dynamic page, where I use $_GET for pages. What I want is a way for a user to see where he/she is on the page, and an easy back-navigation to where they came from. Basically the same as any "normal" breadcrumb-setup, where one traverses the subfolders.

    Given the following page-structure:
    Home
    Page 1
    Sub_page 1
    Sub_page 2
    Page 2
    Page 3
    Page 4
    Sub_page 1
    Page 5

    How would I code something like that? Say a user enters via "home" - then goes to Page 3, and then to Page 4 and then Sub_page 1 on page 4. That would make the following:
    Home > Page 4 > Sub_page 1
    if the user then goes to Page 1 and Sub_page 2, it should display as follows:
    Home > Page 1 > Sub_page 2

    If the user goes back, either by clicking on the links in the breadcrumbs, or by clicking on the page above the current in the menu, the breadcrumb trail should of course loose whatever was after the current page.

    I understand how breadcrumbs works with subfolders, but when all pages are fetched by index.php?page= I'm a bit stumped.

    Anyone have any input on how to do this?
     
    PoPSiCLe, May 20, 2009 IP
  2. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    I might have to look into the first one more closely - it might be able to do what I need it to. Apart from that, they're not really what I'm looking for - at least at first glance. It seems they're both based on categories/tree-structure, with sub-directories. I do not use subdirectories, and I do not have available to me mod_rewrite - neither do I want to make something similar to mod_rewrite in PHP. Therefore, a breadcrumb class/parser that uses "/" as the limiter is sort of useless to me.
     
    PoPSiCLe, May 26, 2009 IP