none
Retrieving Target Audiences Value for a WebPart

    Question

  •  

    Hello,

     

    I'm trying to run an audit on all the Audience usuage throughout our SPS 2007 portal. Our portal is pretty small and some issues have come up which an audit of this kind could solve.

     

    I've been coding a solution and have retrieved the target audience information from all the SPListItems and all the PublishingPages. The only other audience targeting I know of is on individual WebParts but this is where I'm getting stuck. So far I have the following code:

     

    PublishingWeb pw = PublishingWeb.GetPublishingWeb(MyWeb);

    PublishingPageCollection pages = (PublishingPageCollection) pw.PagesList.Items;

    foreach (PublishingPage page in pages)

    {

    if (page.Audience.Length > 0)

    {

    string str = "Page..." + page.Title + " -> " + page.Audience;

    AppendLog(str);

    }

     

    SPLimitedWebPartManager webPartCollection = page.ListItem.File.GetLimitedWebPartManager(PersonalizationScope.Shared);

    foreach (WebPart wp in webPartCollection.WebParts)

    {

      //Log Audience data from wp

    }

     

    Could anyone help?

     

    Thanks very much in advance,

     

    Olly

    Wednesday, January 30, 2008 5:19 PM

Answers