make web.sitemap location dependent

M

mike

I have 2 sites in my company. My .NET site uses a master page and a
Menu control connected to a sitemap. In my sitemap file I would like to
be able to do something like this:

<sitemap>
<sitemapnode site="City1">
<sitemapnode name="home" ... />
***other menu items here***
</sitemapnode>
<sitemapnode site="City2">
<sitemapnode name="home" ... />
***other menu items here***
</sitemapnode>
</sitemap>

When users in City1 or City2 request the home page, ASP.NET recognises
their location (by IP) and loads a location specific Master Page and
home page with a custom menu config. Some of the pages will be common
while others will be specific to the location. In this way, I would
only need to maintain one copy of common pages.

So is this possible without too much fiddling or should I just be
looking for other ways to do this?

Thanks
Mike
 
S

sloan

You need to look into a custom site map provider:

This will allow you to hide items as needed.
Unforunately, you'll have to loop on all items.

Or you can programmatically create the sitemap.



public class GranadaCoderSecureMapProvider : XmlSiteMapProvider
{
public GranadaCoderSecureMapProvider()
{

}


public override bool IsAccessibleToUser(HttpContext context, SiteMapNode
node)
{
//return base.IsAccessibleToUser(context, node);
string currentURL = node.Url;


if (currentURL.Length > 0)
{
//custom functionality here

// here is a simple substitution
return true;

}
return true;



}

}

And web.config section, dealing with this.

<system.web>


<siteMap defaultProvider="XmlSiteMapProvider">
<providers>
<add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider"
siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true" />
<add name ="Company1SiteMap" type ="GranadaCoderSecureMapProvider"
siteMapFile="~/Sitemaps/confirmedUsers.sitemap"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top