Jump to content

Dynamic Breadcrumbs, should I use database?


UrbanDweller
 Share

Recommended Posts

Hey,

 

I'm currently planning on how i will code some breadcrumbs for a shopping site where the admin can add more options/levels to the database which in turn store products. I understand how to get the url of the previous options/level but am stuck on retrieving the name of the level and can only imagine retrieving it from the database. Though Its possible to do so is there any other method as relying on the database for crumbs seems like a easy way out or am i just picky?

 

the typical url is like so:  website.com/shop.php?cat_id=1004, so i cant retrieve the name from it unless i cross reference it to its database name and dont know how to retreive from their <a href> tag.

 

On a side note is there a graph that can show a general outline of how many db queries a server can make per second etc depending on its hardware?

 

Thanks.

Link to comment
Share on other sites

You could use the referrer to know where the user came from, or better, you could store every page viewed in an array in the $_SESSION (to maintain a chain).

 

But that chain has nothing to do with breadcrumbs, which should be a hierarchical representation of where the user is in your site (e.g. Home -> Parent -> Child -> Grandchild

Link to comment
Share on other sites

Breadcrumbs can also refer to the steps the user took to get to that page, a history like you'd see in the drop-down of your back bar. It isn't always the category structure.

 

Well sure you could do history crumbs, but they're useless and confusing (you're basically just mimicking browser.back() functionality, which is why 99.999% of websites that have crumbs do heirarchical crumbs and not historical crumbs.

 

I'm sure you're not suggesting that the OP go with his original intent of crumbing the history... it's a bad idea.  Jakob Nielsen has my back on this one: http://www.useit.com/alertbox/breadcrumbs.html

Link to comment
Share on other sites

I'm simply saying it is one option, and based on what the OP has said, it is the option he is trying to use. Otherwise why ask about the $_SERVER["HTTP_REFERER"} for previous page link?

 

I agree that it's more useful to have it as hierarchy.

Link to comment
Share on other sites

Gotcha... but just because he wants it doesn't mean he understands what he's asking for.  Helping people means more than just giving them what they ask for... it also has to do with understanding what they want / need, and guiding them in the right direction.

Link to comment
Share on other sites

Thanks for the input the main issue was retrieving the previous category name which I had to use the database as I found was the best/easiset solution for my dynamic page as the admin could add more and more categories. So i worked back from the current page via the category parent id all the way to home page which seems to have worked perfectly.

 

I dropped the refeerer idea to as its too risky to create crumb urls

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.