views:

429

answers:

3

In database I have a list of hierarchical list of categories so i construct a Custom Sitemap provider (by extending StaticSiteMapProvider ) with this list of categories.

Now, the page that display articles /ShowArticle.aspx?id=" + Eval("ID") is rewrited into:
/id/article-title.aspx.
So it's not physical exists.

I want the following: When the selected page is displayed I want to display the complete category path in the "Bread crumbs" (every article has a "category" property that contains it's 1 lvl category - without parents)

For example categories structure:

Home  
   Products 
      CdRom
      DvdRom
        Toshiba
   Support
     Hardware 
     Software

When an article id=xx,category=Toshiba, title="Best Toshiba DVD" is opened, the path in "Bread crumbs" should be:
Home|Products|DvdRom|Toshiba|Best Toshiba DVD

How to do it? Should I add something to my custom Sitemap provider?

A: 

I had to look up what the SiteMap provider was, and in doing so accidently came across the answer you may be looking for on the MSDN website: Breadcrumb using SiteMapPath Class

It might not be quite what you are after but it could be a point in the right direction :)

Peter Spain
this is just a standard sitemappath.
markiz
I don't think its a relevant answer as the said link stated about SiteMap only and the asked question is bit differ.
Rick
A: 

We have this kind of situation in one website, what we did is, change the sitemap node text at runtime in the page load event..... I think you to do same....

Muhammad Akhtar
can you please show an example this could be very helpful!
markiz
But I guess there still be a problem, in some situations all nodes must be changed...
markiz
like this you have to put on Article page.....trvSitemap.Nodes[0].ChildNodes[2].Text = "your article text";
Muhammad Akhtar
your nodes hierarchy upto you......... I have just show u sample code
Muhammad Akhtar
A: 

I don't get any answers :(
Maybe I should do like this:
Instead constructing the site map for categories, i should construct it both for categories and all available articles in the database.
It's not efficient (even with caching), but it's the only way i think.

What else can I do?

Update: What is left is just to create dynamically list of links that will act as bread crumbs, when an article is opened it's containing category will be read and full hierarchical categories path will be calculated (from root to this current node).

markiz
What if you change desired node text on article page?? Category 1 -> Article heading text
Muhammad Akhtar
In this case there will be problem if i try to access article directly, like www.mysite.com/articles/category1/category1_2/category1_2_1/123-My-Article
markiz
In my current implementation I retrieve articles just by they Id, i don't need category parameter to get the article. I need categories for navigation.
markiz