0

I have been working on a website which is basically a learning portal and user will have certain lessons inside certain category. My requirement is to build breadcrumbs on the pages. I don't want to hard code at every page.

So could anybody suggest what are the approaches I can use to build breadcrumbs dynamically?

I am using Spring-mvc.

sabu
  • 1,969
  • 4
  • 18
  • 28
  • 1
    This is far too broad. Does your website have a directory-esque structure? If so, you could write a small piece of code to recurse to home and mark the crumbs at each path. – Sébastien Renauld Apr 03 '13 at 15:56
  • Not exactly . Its not completely directory-esque structure. – sabu Apr 03 '13 at 16:02

1 Answers1

0

Usually, if you're talking dynamic breadcrumbs, they are generated by the server-side technology, rather than purely client-side. The server is going to know the exact page structure and what pages are parents of the current pages.

It'd be more unusual and difficult to do entirely client-side, but certainly possible. You might be able to do something like scrape the URL structure to determine parent pages. For example, if they are at /lessons/lesson1/intro you might split that string, compare each value against some dictionary of "Nice" values, and display "Lessons > Lesson 1 > Intro"

Michael Pratt
  • 3,438
  • 1
  • 17
  • 31
  • I was going to write out a JavaScript solution similar to what you mentioned (splitting URL to determine current page, category page, and base URL. Too lazy after seeing you've given him a good starting point, lol. Mine also wouldn't have been flexible; it would only have allowed you to use '2' strings post-base URL. – Minja Apr 03 '13 at 16:04
  • Thanks Michal Pratt and deniatus for the the insight. I kinda thought of similar approach but was wondering, if its ok to follow? – sabu Apr 03 '13 at 16:16