Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access multiple sitemap?

Status
Not open for further replies.

onechuck

IS-IT--Management
Feb 14, 2006
79
US
I'm using Visual Web Developer Express Edition 2005. In my web.config I have this.

<siteMap defaultProvider="XmlSiteMapProvider">
<providers>
<add name="MenuSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" />
<add name="SubMenuSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="lnkPage.sitemap" />
</providers>
</siteMap>

And then in web.sitemap file I have this:

<siteMap xmlns=" >
<siteMapNode url="default.aspx" title="Home" description="myDomain">
<siteMapNode siteMapFile="lnkPage.sitemap" />

<siteMapNode url="welcome.aspx" title="Welcome" description="Welcome">
<siteMapNode url="AboutUs.aspx" title="About Us" description="About Us" />
</siteMapNode>

</siteMapNode>
</siteMap>

Nonw, in my Master page, how do I access the lnkPage.sitemap file?
 
onechuck: I like the looks of this problem; busy at the moment but I shall return - I haven't used the siteMapFile feature of dot NET so interested to see how this one plays out -- later on; if still no takers, I'll help you do a little background research as I am interested in the mechanics as well --
 
Thanks for the interest. From another forum, I got this far. In my web.config file, I have this:

<siteMap defaultProvider="MenuSiteMap">
<providers>
<add name="MenuSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" />
<add name="SubMenuSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="lnkPage.sitemap" />
</providers>
</siteMap>

In my web.sitemap file, I have all my navigational menu; and in my lnkPage.site I have all my page links. Now, it is suggested that I use a method in the code behind so this is what I have.

protected void loadSiteMap()
{

foreach (SiteMapProvider prov in SiteMap.Providers)
{
if (prov.CurrentNode != null)
{
Response.Write(prov.CurrentNode.Title);
}
}
}

However, there is a problem. If the title is in the web.sitemap file then the title displays it twice. If the title is in the lnkPage.site file then it display only once and this is what it suppose to be. Two things, I can't figure out how to make it so it does not display the title twice. Second, I still don't understand how it is able to pull the title out of either the two .sitemap files. Is there a way to control when to pull the title from which file?
 
onechuck: Thanks for posting back. I'll have a few minutes here soon and I am going to reproduce what you have and test it as well (I too am in the middle of buidling a web site in asp.net) and so am very much interested in this built-in Sitemap capability. No worrries, we'll get this figured out.
 
Okay, I got it figured out now. All I have to do is put a break; after the respose write line.

Now, one other issue though...since I'm using breadcrumb from the sitemap file, it's not showing anything if the title is listed in the lnkPage.sitemap and not the web.sitemap default provider.
 
onechuck: to save me a bit of time can you defince where in the web.config your statmenet goes; as well what is the file extension of web.sitemap file (I suppose it is simply web.sitemap). I'd like to build this and give it test run.
 
In the web.config:

<siteMap defaultProvider="MenuSiteMap">
<providers>
<add name="MenuSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" />
<add name="SubMenuSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="lnkPage.sitemap" />
</providers>
</siteMap>

The extension is .sitemap
 
onechuck:having one of those weeks; hang in there, we'll get this soon enough - I am not working under Visual Studio but I should be able to reproduce the results - I'm trying to make some time later this afternoon - perhaps someone will drop by with their 2 cents - sorry for the dealy onechuck; this is a very interesting problem and I'm sure well get to the bottom of it - I take it you have done a pretty thorough search on Google/Groups, etc?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top