Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to build a megamenu with two levels of personalization for every user:

  • Filtered links driven by list-based content. I'm using a DVWP for this. The DVWP is all set up and works great in a standalone aspx page.
  • Links coming from User Profile properties. This is almost a no-brainer if I do it with jQuery and SPServices client-side.

We can't seem to get a control into the master page (it has to be the master page because this is the top nav we're talking about) that contains the User Profile value I need to filter the DVWP. It's not a problem to have the value show up in a control in the browser, but the page pipeline seems to populate the control after the DVWP is emitted.

In a page or page layout, we can use the Current User Filter Web Part (CUFWP) to grab the User Profile Property that we want. However, the CUFWP can't be in the master page, as it throws the error

The Hidden property cannot be set on Web Part ‘g_8271d6f6_a902_4fa4_88ce_ca9ae1b0d463′, since it is a standalone Web Part.

I don't want to render the whole top nav in script using SPServices to grab the list-based content because that would introduce an uncomfortable lag on page load, which would be bad UX. (Though doing this wouldn't be very hard.)

Any ideas on how to expose a User Profile property in the master page at the right time in the page pipeline?

share|improve this question
    
Would making the DVWP load asynchronously make any difference here? –  PirateEric Aug 3 '12 at 11:55
    
Suggestion on how that might work? Do you mean the refresh capability? It would still mean it wouldn't be right on first load, though, I think. –  Marc D Anderson Aug 3 '12 at 11:57
    
Wouldn't it function like calendar web parts in that the framework is there on page load then the data is loaded after the fact? Or, the DVWP could live on a separate page and loaded in via ajax with a doc ready jQuery function? –  PirateEric Aug 3 '12 at 11:59
    
That would still introduce a delay, and we'd still have the User Profile property issue, though, right? –  Marc D Anderson Aug 3 '12 at 12:00
    
I wouldn't think so in regards to the property issue, because couldn't you specify a current user filter there, ajax it in, and it's just the same as being filtered by your property? –  PirateEric Aug 3 '12 at 12:07
show 2 more comments

3 Answers

up vote 1 down vote accepted

An approach I've used that may work is to have a DVWP exist on a separate page attached to your master page in a document library. The DVWP would be filtered by the current logged in user.

Then using jQuery, make an AJAX call to fetch that page, dropping in the contents of the DVWP where desired.

function reload() {
$.ajax({
   async: false,
   cache:false,
   url: "/sites/training/User/UpcomingCourses.aspx",
   complete: function (xData, Status) {
    var DVWPMarkup = $(xData.responseText).find("#offerings").html();
    $("#offer").html(DVWPMarkup);
    }
});
}

$(document).ready(function(){ 
reload();
});

The list internally has a good chunk of data and this doesn't feel too laggy in our 2007 environment. Maybe it'll work in your situation.

share|improve this answer
    
At the moment, this is looking like the best solution. If you add your script right below the $("#offer") element, you shouldn't even need to use $(document).ready(), as you're sure the element already exists. I need to do some more testing, but I think this is the winner! –  Marc D Anderson Aug 6 '12 at 16:07
    
True, this wasn't my full code but adapted for this question. Mine lives in a doc ready as this refreshes itself every 30 seconds for a poor man's 2007 version of ajax refreshable web parts in 2010. –  PirateEric Aug 6 '12 at 16:18
    
Eric: Excellent suggestion, and thanks! –  Marc D Anderson Aug 6 '12 at 16:52
add comment

The master page of the mysite is the normal v4.master and doesn't load any user profile. There is a web control in every article page in the mysite that makes sure the profile gets loaded.

<SPSWC:ProfilePropertyLoader id="m_objLoader" LoadFullProfileOfCurrentUser="true" runat="server" />

If you like to get this done in the masterpage you need to add the webcontrol with a custom tag prefix. The namespace for this control needs to be registered in the header of the master page too. The registration for the profile loader use the following registration.

<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

You need a new tag prefix because otherwise you will get a conflict between the one on the master page and the one in the person.aspx. So in your case it has to look something like this on the masterpage:

<%@ Register Tagprefix="MyCustomTagPrefix" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

and somewhere in the master page you the need to add.

<MyCustomTagPrefix:ProfilePropertyLoader id="m_objLoader" LoadFullProfileOfCurrentUser="true" runat="server" />

Then the user profile will be loaded right away on masterpage loading time not at the time the article page is loaded. It might is needed that you remove the the ProilePropertyLoader from the article page.

I'm not really sure if this will help you are not but. It could be a reason why it loads on the article but not the master page. What you then can do too should be to load a specific property from the profile store using the following web control.

<MyCustomTagPrefix:ProfilePropertyValue PropertyName="Department" runat="server"/>

To display the department of the user for example.

share|improve this answer
    
We've tried basically this, though hadn't used a custom tag prefix or included LoadFullProfileOfCurrentUser="true". I tried both, but I'm still not seeing values. Thanks a lot for the idea; I'm going to keep working at it. –  Marc D Anderson Aug 3 '12 at 18:00
    
Oh, and we're not doing this in the My Site; it's in the master page for regular Site Collections. We want the top nav to be personalized everywhere. –  Marc D Anderson Aug 3 '12 at 18:17
    
I think it's the same with a site collection because we once had to include WP from the masterpage into a normal portal an we used this. Are you able to show me exactly what you try to do? –  Stefan Bauer Aug 3 '12 at 19:57
add comment

Marc,

Can you lose the DVWP and just use JQuery for the whole thing? THen you could control the load of the page User Profile Values by hitting the USer Profile Web Service with a JQuery request.

Alternatively can you use an audience on the list so you avoide the call to the User Profile alltogether?

Matthew

share|improve this answer
    
Matthew: jQuery all the way would certainly get the content in the page just fine. What I'm worried about is the lag on page load. I'd prefer to get as much done as possible server side. –  Marc D Anderson Aug 3 '12 at 23:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.