SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help me understand the crumbs in very simple steps?

    Hi,

    I am new the forum and javascript. I am trying to understand how breadcrumbs work, but am unable to find a tutorial that would break the whole process down in very simple terms. I understand how the crumbs work once placed on a web page, but would appreciate it if someone can break the steps down in right sequence

    Thank you.
    combustion

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is not something that should be done with javascript. It should be done on the server side because it makes it easier to keep track of where the user is within a hierarchy. There are probably a variety of ways to do this but the simplest is probably to simply have a large tree containing everything (perhaps as a large multidimensional array) and you locate where the user is and then build the breadcrumbs from there. If the URL is a direct reflection of the hierarchy, then you could just build it directly from the URL. Or if the hierarchy is related to the directory structure, you could also do that (unless it's the same thing as doing it via the URL).

    Have a look on google for something like "php breadcrumbs" (or whatever your server-side programming language of choice is).

  3. #3
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    NYC
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Raffles,

    thank you for all your help. I would still appreciate a walk-through or a step by step breakdown, like how many basic steps are there in writing the crumb script.

    Thanks.

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, it depends very much on what you're going to base it on. Are you going to base it on directory structure, URL or a predefined array that represents the entire tree of possible breadcrumb routes? You could also have some system where you query a database with some parameters and it returns the breadcrumb thread.

    In very general terms, you would do this:
    • Somehow obtain the breadcrumb data into an array
    • Loop through the array
    • In each iteration, create an anchor (<a>) with the iteration's data followed by a symbol to indicate it's the parent of whatever comes next
    • At the end of the iteration, do a check to see if it's the last element in the array. If this is the case, don't output the symbol.


    You might want to mark it up with a list (<ol>) or just put it all in a <div> or <p>.

    But like I said, it depends where you're going to get the breadcrumb data from.

  5. #5
    SitePoint Member
    Join Date
    Aug 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At least, now I know the choices which I am very thankful to you. I didn't even know that there were other choices regarding crumbs.

    First thing, I would now do is to learn to read the breadcrum data and split it into an array.

    thanks.


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
  •