SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot The Big Show's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zend's PHP Breadcrumbs Code

    http://www.zend.com/zend/spotlight/breadcrumb28.php

    Has anybody gotten this to work? I'm a relative PHP newbie, so if the code given is just a function, I would not have the know-how to print the breadcrumbs out. Thanks in advance for your help,

    The Big Show
    "It's Showtime"

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks to me like you would use the function they provide like this:
    PHP Code:
     function breadcrumb_nav($basename_=_"Home")
    {
        
    // insert their code here
    }
    // now to get it on the screen... either:
    echo(breadcrumb_nav());
    // or:
    $the_breadcrumb_text breadcrumb_nav();
    echo(
    $the_breadcrumb_text); 
    If that doesn't work, post back and we'll figure it out.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  3. #3
    SitePoint Zealot The Big Show's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both versions of the echo work. Thanks for the help. Much appreciated

    Also, is it possible using this code to take the breadcrumbs an additional step further to individual files and not only directories? For example:

    It currently displays

    Home > Directory A

    for http://www.mysite.com/directorya/

    Would it be possible to have it display

    Home > Directory A > Main

    for http://www.mysite.com/directorya/index.php?id=main


    The Big Show
    "It's Showtime!"

  4. #4
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/manual/en/function.ucwords.php

    Yes, that is possible!

    The "main" in the url can be accessed as $_GET['id']

    So lets say you used method B and got $the_breadcrumb_text variable. Then you could:
    PHP Code:
    $this_page ucwords($_GET['id']);
    $the_breadcrumb_text_ .= " > $this_page";
    echo(
    $the_breadcrumb_text); 
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  5. #5
    SitePoint Zealot The Big Show's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by samsm
    http://www.php.net/manual/en/function.ucwords.php

    Yes, that is possible!

    The "main" in the url can be accessed as $_GET['id']

    So lets say you used method B and got $the_breadcrumb_text variable. Then you could:
    PHP Code:
    $this_page ucwords($_GET['id']);
    $the_breadcrumb_text_ .= " > $this_page";
    echo(
    $the_breadcrumb_text); 
    It doesn't seem to be working. Perhaps the original function needs to be modified?

  6. #6
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like it should work to me

    Could you post your code and what is going wrong?
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  7. #7
    SitePoint Zealot The Big Show's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    $this_page 
    ucwords($_GET['id']);
    $the_breadcrumb_text_ .= " > $this_page";
    $the_breadcrumb_text breadcrumb_nav();
    echo(
    $the_breadcrumb_text); 
    How should the new code be added in regard to method B? Should it be placed alongside it or replace it completely?
    Last edited by The Big Show; Nov 26, 2002 at 16:49.

  8. #8
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should have the whole function (from Zend) above the code you just posted

    Basically:
    PHP Code:
    function_breadcrumb_nav($basename "Home")
    {
        
    // insert their code here
    }
    $the_breadcrumb_text breadcrumb_nav();
    $this_page ucwords($_GET['id']);
    $the_breadcrumb_text  .= " > $this_page";
    echo(
    $the_breadcrumb_text); 
    Last edited by samsm; Nov 27, 2002 at 09:37.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  9. #9
    SitePoint Zealot The Big Show's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by samsm
    You should have the whole function (from Zend) above the code you just posted

    Basically:
    PHP Code:
    function_breadcrumb_nav($basename "Home")
    {
        
    // insert their code here
    }
    $the_breadcrumb_text breadcrumb_nav();
    $this_page_=_ucwords($_GET['id']);
    $the_breadcrumb_text  .= " > $this_page";
    echo(
    $the_breadcrumb_text); 
    I do have it...I just thought that went without saying

  10. #10
    SitePoint Zealot The Big Show's Avatar
    Join Date
    Nov 2002
    Location
    USA
    Posts
    157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It gives me the following error: Fatal error: Call to undefined function: _ucwords()

  11. #11
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by The Big Show
    It gives me the following error: Fatal error: Call to undefined function: _ucwords()
    A stray character made it into the php. Make sure you have delete that underscore character before the "ucwords" and replace it with a real space. I was recently in a thread where someone had the same problem, you might look at this thread for more details: http://www.sitepointforums.com/showt...255#post613255
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  12. #12
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Modesto, CA
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do peeps post code like this? Why not just post code with the space?

    PHP Code:
    $this_page_=_ucwords($_GET['id']); 
    It should be (remove the _)

    PHP Code:
    $this_page ucwords($_GET['id']); 

  13. #13
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The space is invisable when cutting and pasting... I tried to remove all the little buggers I just missed one. Oops.

    I don't know if you looked at the thread I mentioned, but every single time I copy php off these boards (doesn't matter who posted the php) every single space turns into that wacky underscore character. As you can see from the thread referenced, at least several people have this problem.

    Once IE for OSX allows text services to be used on text selections, I will never leave a phantom space in a post. For now, I missed one
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •