Acessing the underlying listitem for a PortalWebSiteMapNode in the PortalSiteMapProvider

I am using the Web Content Management Feature og MOSS2007 to build a Internet presence web-site for a client.

I have made my own implementation of the PortalSiteMapProvider, that returns an hierachical view of my site/pages structure, i bind this to a MOSSMEnu control and everything works like a charm..

However my my client requires that some of the menu items should be color coded, depending on one of the properties set in the underlying listitem (Page) of the PortalWebSiteMapNode.

How is this done? I have looked at the PortalWebSiteMapNode, and PortalSiteMapProvicer objects, but i have not found any obvious way to do this.

The only thing i can think of is binding to the listitem using the URL, but that does not appear to be a valid approach because of performance reasons.

Any help would greatly appreciated!!!!

PS: I originally posted this in the Programming Forum, but this is the right spot for it soory about the cross post

[982 byte] By [MortenAndreasen] at [2008-2-4]
# 1

Accessing the underlying list item will always be a perf issue. However, it turns out that the Portal*SiteMapNode classes were designed to handle this. We actually cache all of the custom properties of a web (the property bag) which can be indexed by the property name. I think the API is simply node["Property"].

Likewise, the fields of the associated list item are also cached, and can be accessed in a similar manner, where the accessor is either the field name, the internal name, or the field ID (Guid). You will need to cast the SiteMapNode to the correct type before using the accessor.

As an aside, the PortalSiteMapProvider also allows you to cache SPQuery results as well as SPSiteData queries.

Hope that helps

Pat.

PatMiller-MSFT at 2007-9-6 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Enterprise Content Management...
# 2

Thanks Pat

I kindof figured it out myself because i noticed that the PortalWebSiteMapNode had a method called GetProperty, which returned values from the property bag

Since the method was missing on the PortalListItemSiteMapNode i figured that it was not possible to retrive properties from listItems - but the PortalListItemSiteMapNode ["Property"] indexer works like charm.

Hovever you cannot use the ["Property"] index on PortalWebSiteMapNodes - use GetProperty("Property")

object property = null;

if (smn is PortalWebSiteMapNode)
{
PortalWebSiteMapNode pwsmn = (PortalWebSiteMapNode)smn;
property = pwsmn.GetProperty("CSSClass");
}
else if (smn is PortalListItemSiteMapNode)
{
PortalListItemSiteMapNode plismn = (PortalListItemSiteMapNode) smn;
object property = plismn["CSSClass"];
}
if (property != null)
{
e.Item.Value = property as string;
}

BTW: What do you mean by "PortalSiteMapProvider also allows you to cache SPQuery results as well as SPSiteData queries" ?

MortenAndreasen at 2007-9-6 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Enterprise Content Management...
# 3

I can see how the properties would be somewhat confusing. It stems from the underlying objects (SPWebs and SPListItems) where SPWebs have a property bag accessed by .Properties, and an SPListItem has a set of fields that are accessed by the this[] operator.

As for the last point (PortalSiteMapProvider being able to cache SPQuery and SPSiteData results):

The method PortalSiteMapProvider::GetCachedSiteDataQuery and PortalSiteMapProvider::GetCachedListItemsByQuery will do this.

In a nutshell, you get the PortalWebSiteMapNode that represents the SPWeb that you would normally make the call against (or the web that the SPList exists in), and you pass in the query (and the list to query in the case of GetCachedListItemsByQuery) and an SPWeb that has been opened in the context of the user that you want to fetch the items for. This SPWeb is used to security trim the result sets. Normally you would simply use SPContext.Current.Web, but in the case of command line apps or apps where you want to get data as the system or some other account, you can simply get any web as the user you want to security trim as.

Hope that helps.

Pat.


This posting is provided "AS IS" with no warranties, and confers no rights.

PatMiller-MSFT at 2007-9-6 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Enterprise Content Management...
# 4

Hi Morten,

I need to implement a site hierarchy , in which a user is able to access the sites in which he has any kind of access( owner, member , visitor , or user is directly added to the site not to any group in site , or any group) in the following manner:

-Web application 1

--Top Site 1

-- Child Site 1

-- child site 2

-- Top Site 2

-- CHils site 1

- web application 2

--Top Site 1

-- Child Site 1

-- child site 2

-- Top Site 2

-- CHils site 1

I have catagorised the questions to implement this one :

a) How to find out user belongs to any group of a site

b) which UI control to use to display the data ?

For UI control - SPgridview, SP treeview are possibel candidates -- but dont know how.

to find out how a user belongs to a group - this also i dont have complete knowledge , but

for owner, member, visiotr group , we have some property bag - VT_ASSOCIATEMEMBERGROUP, VT_ASSOCIATEOWNERGROUP,VT_ASSOCIATEVISITORGROUP

Can PortalSiteMap be used for this requirement ?

Please share your experience in implementing this SITE hierarchy?

Thanks,

Vipin

vipintanwar at 2007-9-6 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Enterprise Content Management...
# 5

Can you please tell me the implementation skeleton, Ive referred to http://msdn2.microsoft.com/en-us/library/ms558975.aspx, but it misses something which I dont know, also http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1958613&SiteID=1 where Ive just implemented a StaticSiteMap provider.

Any help would be greatly appreciated

Rgds

Kumarakuru at 2007-9-6 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Enterprise Content Management...

SharePoint Products and Technologies

Site Classified