I have seen some posts about navigation and breadcrumbs but did not find the exaxt same problem. However if there is, please forgive and point me to it. Thank you.
My case :
Interests Profiles
| |
|_Interest Area 1 |-Profile Area 1
| | |
| |_Interest Area 1.1 |_List of Books
| | |
| |_List of Books |_Book Detail
| |
| |_Book Detail
|_Interest Area 2
|
|_List of Books
|
|_Book Detail
The hierarchy is stored in the database. The entry points Interests and Profiles are fixed. From there I don't know what the children will be.
When there is no child left anymore, the books get retrieved based on the value of the last selected (sub)category.
I have two problems here: 1st: Creating the appropriate routes. The way I would like it is:
/books/{id}/{interestareaname}/{subinterestareaname}/{books}/{page}
where interestareaname is added for user friendly urls and keeps getting repeated as long you go down the hierarchy. The output would then be: /books/1/project-management/prince2/books/1 this shows the prince2 books on paged listpage page 1.
But when there is only one level it the route contains only one interestareaname and thus becomes this:
/book/{id}/{interestareaname}/{books}/{page}
What I did to solve problem number 1:
routes.MapRoute(
"Details",
"view/details/{id}/{booktitle}",
new { controller = "book", action = "Details", id = "*", booktitle= "*"});
routes.MapRoute(
"interests",
"books/{id}/{level1}/{level2}/{level3}/{page}",
new { controller = "book", action = "books", level1 = "*", level2 = "*", level3 = "*", id = "0", page = UrlParameter.Optional }
);
routes.MapRoute(
"profiles",
"books/{id}/{level1}/{level2}/{level3}/{page}",
new { controller = "book", action = "books", level1 = "*", level2 = "*", level3 = "*", id = "0", page = UrlParameter.Optional }
);
I got to this by stating that a max level should be set. That is only because I didnt know how to make it more dynamic.
The problem now is to differentiate between the interests categories and the profile categories. I did that by creating a same route, but with different name and added the route name in the sitemap creation.
The 2nd problem I have is the sitemap and the breadcrumbs. I use the MVCsitemapprovider and the DynamicNodes functionality.
With the sitemap I have a problem showing the details page. Because the books will appear both on profiles and on interests. And some books will appear in multiple interest areas or profiles. In each case I would like to see the path I used to get to that book.
First I added the detail pages for each book to the sitemap, but that was crazy. And creates duplicate entries which are not handled very well by sitemaps. Other option was to pass the routedata on the list page to the details page by querystring, but that looked awful and I have then to add logic to parse the querystring to mimic the breadcrumb, which will be hard, since I only have the ID then of the lowest level.
I have spent now many nights and I still can´t figure it out. If some one can help or point me to the right direction I am very grateful.