visibility improvement

May 26, 2009 at 12:55 PM

Hi!

For Asp.Net WebForms I used

SmartSiteMapProvider 
http://www.csharper.net/blog/sitemapprovider_doesn_t_take_querystring_into_consideration.aspx#custom_sitemapprovider_incorporates_querystring_reliance.aspx

I also added some functionality to it. And the most used one was visibility with value reliant:

<siteMapNode url="~/test/edit.aspx" title="EDIT" reliantOn="id" visible="reliant" />

It basically draws a link if parameter id is present, if there isn't it acts like InSiteMapPathOnly.

 

Example:

/Test/Details    shows empty page and maybe some text like "Nothing is selected"

/Test/Details/123 shows details for the object with Id 123 and in the Menu generated from siteMap extra options are drawn (like Edit this object, View Extra object data, Add extra object data....)

 

Comments?

Coordinator
May 27, 2009 at 7:17 AM

Sounds great, though I am still a bit confused with the concept. Can you write up an example of how you see this in MvcSiteMap?

May 27, 2009 at 8:09 AM

Hi!

Example:

I did this with Asp.Net WebForms.

Let's say we have a web app that you can edit user data and users can have one ore more bank accounts.

This is the sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/Default.aspx" title="MAIN">
    <siteMapNode url="~/Users/Default.aspx" title="USERS" reliantOn="kid">
      <siteMapNode url="~/Users/AddUser.aspx" title="ADD USER" />
      <siteMapNode url="~/Users/EditUser.aspx" title="EDIT USER" reliantOn="kid" visible="reliant" />
      <siteMapNode url="~/Users/UserBankAccounts.aspx" title="USER BANK ACCOUNTS" reliantOn="kid" visible="reliant" />
      <siteMapNode url="~/Users/AddBankAccount.aspx" title="ADD BANK ACCOUNT" reliantOn="kid" visible="reliant" />
      <siteMapNode url="~/Users/EditBankAccount.aspx" title="EDIT BANK ACCOUNT" reliantOn="kid,rid" visible="false" />
    </siteMapNode>
  </siteMapNode>
</siteMap>

 

So let's view what we see on different URLs:

http://localhost/Users/Default.aspx  (shows USERS, ADD USER)

EDIT USER, USER BANK ACCOUNTS, ADD BANK ACCOUNT are not shown because the reliantOn parameter kid is NOT present and visible is set to reliant.

 

http://localhost/Users/Default.aspx?kid=1 (shows USERS, ADD USER, EDIT USER, USER BANK ACCOUNTS, ADD BANK ACCOUNT)

EDIT USER, USER BANK ACCOUNTS, ADD BANK ACCOUNT are shown because the reliantOn parameter kid is present and visible is set to reliant.

 

 

So if we translate this to MVC:

http://localhost/Users/Index  (shows USERS, ADD USER)

http://localhost/Users/Index/1 (shows USERS, ADD USER, EDIT USER, USER BANK ACCOUNTS, ADD BANK ACCOUNT)

 

 

Is it any clearer now?

Coordinator
May 27, 2009 at 12:55 PM

Makes sense! Will see what I can do to get this in as soon as possible.