<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Waldek Mastykarz</title>
	
	<link>http://blog.mastykarz.nl</link>
	<description>Innovation Matters | SharePoint Server MVP | ISSN 2210-9390</description>
	<lastBuildDate>Sun, 05 Feb 2012 14:10:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/WaldekMastykarz" /><feedburner:info uri="waldekmastykarz" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Inconvenient provisioning Web Parts to Wiki Pages in Sandboxed Solutions</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/rP34yvyikTE/</link>
		<comments>http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 14:10:48 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Inconvenient SharePoint]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Structured and repeatable deployment]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/</guid>
		<description><![CDATA[Sandboxed Solutions are a powerful way to create SharePoint 2010 Solutions in a secure manner. The price of security however is limited access to the SharePoint API which makes it challenging to accomplish certain tasks like provisioning Web Parts to Wiki Pages. Find out how to provision Web Parts to Wiki Pages in Sandboxed Solutions. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="Visual Studio 2001 Properties window showing properties of a SharePoint Project" src="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/banner.jpg" width="471" height="110" />     <br />Sandboxed Solutions are a powerful way to create SharePoint 2010 Solutions in a secure manner. The price of security however is limited access to the SharePoint API which makes it challenging to accomplish certain tasks like provisioning Web Parts to Wiki Pages. Find out how to provision Web Parts to Wiki Pages in Sandboxed Solutions.</p>
<h2>Playing in the Sandbox</h2>
<p>The introduction of Sandbox in SharePoint 2010 empowers both IT-Pros and Developers. Using Sandboxed Solutions developers can deliver rich solutions that leverage the SharePoint 2010 capabilities. Because those solutions are executed in an isolated fashion and have limited access to the SharePoint API and the .NET Framework, there are less risks involved with deploying and using them in a SharePoint Farm. One more important benefit of using Sandboxed Solutions is, that they require less involvement from IT departments as they can be deployed and managed by Site Collection Administrators.</p>
<p>In SharePoint 2007, where no Sandbox was available, designing SharePoint Solutions was a lot like all or nothing: either developers were allowed to create solutions with custom code and had virtually access to the full SharePoint API and .NET Framework or SharePoint Farms were sealed, no custom code would be allowed and developers were tasked with the challenge to get things to work using nothing more than the standard functionality of the SharePoint platform. As you can imagine neither of those two approaches is perfect. Allowing developers to use the full API means you have to spend more time on security-testing their work and narrowing the options to standard functionality only means that not the solution but the technical capabilities are central and there is a chance that business might get not the solution that they need, not to mention the extra effort required to “just get things done”.</p>
<p>Sandboxed Solutions offer added value to SharePoint developers allowing them to use their knowledge to build secure solutions. And although the API available for Sandboxed Solutions gives developers the ability to interact with data stored in SharePoint, it might be too limited to complete all tasks and provide end users with fully working solutions instead of a collection of building blocks and a manual.</p>
<h2>Inconvenient provisioning Web Parts instances from Sandboxed Solutions</h2>
<p>One of the challenges when working with Sandboxed Solutions is how to provision Web Parts instances to pages. If you have done this before in a Farm Solution you know, that in order to add a Web Part to a page programmatically in SharePoint you have to retrieve the instance of the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.splimitedwebpartmanager.aspx?ocid=aff-n-we-loc--ITPRO40936&amp;WT.mc_id=aff-n-we-loc--ITPRO40936">SPLimitedWebPartManager</a> class and use it to add the instance of a Web Part to a page. Unfortunately, as the SDK mentions, the SPLimitedWebPartManager class is not available in Sandboxed Solutions which means that you cannot programmatically add a Web Part to a page from within a Sandboxed Solution.</p>
<p>Luckily the programmatic approach isn’t the only option that SharePoint offers for adding Web Parts to pages. It turns out that there is a declarative approach as well, which is just perfect for when you need to provision a Web Part instance from within a Sandboxed Solution.</p>
<h3>Declaratively provisioning Web Part instances to pages</h3>
<p>Declaratively provisioning Web Part instances to pages is easy and can be done using a Module. The following code snippet shows how you can add a Content Editor Web Part with the <em>Hello world</em> text to a Web Part Page:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;
  &lt;Module Name=&quot;HomePage&quot;&gt;
    &lt;File Path=&quot;HomePage\default.aspx&quot; Url=&quot;default.aspx&quot;&gt;
      &lt;AllUsersWebPart WebPartOrder=&quot;0&quot; WebPartZoneID=&quot;Left&quot;&gt;
        &lt;![CDATA[&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;WebPart xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns=&quot;http://schemas.microsoft.com/WebPart/v2&quot;&gt;
  &lt;Title&gt;Content Editor&lt;/Title&gt;
  &lt;FrameType&gt;Default&lt;/FrameType&gt;
  &lt;Description&gt;Allows authors to enter rich text content.&lt;/Description&gt;
  &lt;IsIncluded&gt;true&lt;/IsIncluded&gt;
  &lt;ZoneID&gt;Left&lt;/ZoneID&gt;
  &lt;PartOrder&gt;0&lt;/PartOrder&gt;
  &lt;FrameState&gt;Normal&lt;/FrameState&gt;
  &lt;Height /&gt;
  &lt;Width /&gt;
  &lt;AllowRemove&gt;true&lt;/AllowRemove&gt;
  &lt;AllowZoneChange&gt;true&lt;/AllowZoneChange&gt;
  &lt;AllowMinimize&gt;true&lt;/AllowMinimize&gt;
  &lt;AllowConnect&gt;true&lt;/AllowConnect&gt;
  &lt;AllowEdit&gt;true&lt;/AllowEdit&gt;
  &lt;AllowHide&gt;true&lt;/AllowHide&gt;
  &lt;IsVisible&gt;true&lt;/IsVisible&gt;
  &lt;DetailLink /&gt;
  &lt;HelpLink /&gt;
  &lt;HelpMode&gt;Modeless&lt;/HelpMode&gt;
  &lt;Dir&gt;Default&lt;/Dir&gt;
  &lt;PartImageSmall /&gt;
  &lt;MissingAssembly&gt;Cannot import this Web Part.&lt;/MissingAssembly&gt;
  &lt;PartImageLarge&gt;/_layouts/images/mscontl.gif&lt;/PartImageLarge&gt;
  &lt;IsIncludedFilter /&gt;
  &lt;Assembly&gt;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;/Assembly&gt;
  &lt;TypeName&gt;Microsoft.SharePoint.WebPartPages.ContentEditorWebPart&lt;/TypeName&gt;
  &lt;ContentLink xmlns=&quot;http://schemas.microsoft.com/WebPart/v2/ContentEditor&quot; /&gt;
  &lt;Content xmlns=&quot;http://schemas.microsoft.com/WebPart/v2/ContentEditor&quot;&gt;Hello world&lt;/Content&gt;
        &lt;PartStorage xmlns=&quot;http://schemas.microsoft.com/WebPart/v2/ContentEditor&quot; /&gt;
        &lt;/WebPart&gt;]]&gt;&lt;/AllUsersWebPart&gt;
    &lt;/File&gt;
  &lt;/Module&gt;
&lt;/Elements&gt;</pre>
<blockquote>
<p><strong>Important:</strong> to provision a Web Part to a Web Part Page you will need a Web Part Page file. You can copy the default Web Part Page file from 14\TEMPLATE\SiteTemplates\sts\default.aspx.</p>
</blockquote>
<p><a href="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/01.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Content Editor Web Part added to a Web Part Page in SharePoint 2010" src="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/01_thumb.jpg" width="480" height="383" /></a></p>
<p>As you can see adding Web Parts to Web Part Pages is fairly easy. The challenge begins however as soon as you start working with Wiki Pages.</p>
<h3>Declaratively provisioning Web Part instances to Wiki Pages</h3>
<p>One of the new features introduced with SharePoint 2010 was the concept of adding Web Parts in content. Before that we had to use Content Editor Web Parts to store content if we wanted to use Web Parts in between. With SharePoint 2010 we could just type rich content and insert Web Parts in between just as if we were adding images or tables.</p>
<p>The Web Parts in content capability has been made available in Publishing Sites as well as Collaboration Sites. The only requirement with regards to Collaboration Sites is, that you have to be using Wiki Pages. A while ago I wrote <a href="http://blog.mastykarz.nl/programmatically-adding-web-parts-rich-content-sharepoint-2010/">an article about how you can add Web Part instances to content</a>. The approach I presented involved using custom code which unfortunately cannot be used from within Sandboxed Solutions as it relies on the SPLimitedWebPartManager class. However using the same information about how Web Parts in content work behind the scenes, we can alter the declarative approach used for Web Part Pages to add a Web Part to a Wiki Page. The following code snippet presents the Module modified to add the Content Editor Web Part to a Wiki Page:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;
  &lt;Module Name=&quot;HomePage&quot;&gt;
    &lt;File Path=&quot;HomePage\wkpstd.aspx&quot; Url=&quot;SitePages/Home.aspx&quot;&gt;
      &lt;Property Name=&quot;WikiField&quot; Type=&quot;string&quot; Value=&quot;
&amp;lt;div class=&amp;quot;ms-rtestate-read ms-rte-wpbox&amp;quot; contentEditable=&amp;quot;false&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ms-rtestate-read 46113482-da36-45a5-bbac-e1e1771c19fa&amp;quot; id=&amp;quot;div_46113482-da36-45a5-bbac-e1e1771c19fa&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div style='display:none' id=&amp;quot;vid_46113482-da36-45a5-bbac-e1e1771c19fa&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;
      &quot;/&gt;
      &lt;AllUsersWebPart WebPartOrder=&quot;0&quot; WebPartZoneID=&quot;wpz&quot; ID=&quot;g_46113482_da36_45a5_bbac_e1e1771c19fa&quot;&gt;
        &lt;![CDATA[&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;WebPart xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns=&quot;http://schemas.microsoft.com/WebPart/v2&quot;&gt;
  &lt;Title&gt;Content Editor&lt;/Title&gt;
  &lt;FrameType&gt;Default&lt;/FrameType&gt;
  &lt;Description&gt;Allows authors to enter rich text content.&lt;/Description&gt;
  &lt;IsIncluded&gt;true&lt;/IsIncluded&gt;
  &lt;ZoneID&gt;Left&lt;/ZoneID&gt;
  &lt;PartOrder&gt;0&lt;/PartOrder&gt;
  &lt;FrameState&gt;Normal&lt;/FrameState&gt;
  &lt;Height /&gt;
  &lt;Width /&gt;
  &lt;AllowRemove&gt;true&lt;/AllowRemove&gt;
  &lt;AllowZoneChange&gt;true&lt;/AllowZoneChange&gt;
  &lt;AllowMinimize&gt;true&lt;/AllowMinimize&gt;
  &lt;AllowConnect&gt;true&lt;/AllowConnect&gt;
  &lt;AllowEdit&gt;true&lt;/AllowEdit&gt;
  &lt;AllowHide&gt;true&lt;/AllowHide&gt;
  &lt;IsVisible&gt;true&lt;/IsVisible&gt;
  &lt;DetailLink /&gt;
  &lt;HelpLink /&gt;
  &lt;HelpMode&gt;Modeless&lt;/HelpMode&gt;
  &lt;Dir&gt;Default&lt;/Dir&gt;
  &lt;PartImageSmall /&gt;
  &lt;MissingAssembly&gt;Cannot import this Web Part.&lt;/MissingAssembly&gt;
  &lt;PartImageLarge&gt;/_layouts/images/mscontl.gif&lt;/PartImageLarge&gt;
  &lt;IsIncludedFilter /&gt;
  &lt;Assembly&gt;Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&lt;/Assembly&gt;
  &lt;TypeName&gt;Microsoft.SharePoint.WebPartPages.ContentEditorWebPart&lt;/TypeName&gt;
  &lt;ContentLink xmlns=&quot;http://schemas.microsoft.com/WebPart/v2/ContentEditor&quot; /&gt;
  &lt;Content xmlns=&quot;http://schemas.microsoft.com/WebPart/v2/ContentEditor&quot;&gt;​Hello world&lt;/Content&gt;
        &lt;PartStorage xmlns=&quot;http://schemas.microsoft.com/WebPart/v2/ContentEditor&quot; /&gt;
        &lt;/WebPart&gt;]]&gt;&lt;/AllUsersWebPart&gt;
    &lt;/File&gt;
  &lt;/Module&gt;
&lt;/Elements&gt;</pre>
<blockquote>
<p><strong>Important:</strong> Note that the Wiki Page uses a different page file that can be copied from 14\TEMPLATE\DocumentTemplates\wkpstd.aspx</p>
</blockquote>
<p><a href="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/02.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Content Editor Web Part added to a Wiki Page in SharePoint 2010" src="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/02_thumb.jpg" width="480" height="370" /></a></p>
<p>If you took a careful look at the code snippet you might have noticed that a few things have changed. First of all we changed the page’s URL to <em>SitePages/Home.aspx</em> (line 4) so that it points to a Wiki Page instead of a Web Part Page. Next we added the <em>WikiField</em> property (lines 5-7) which contains the content of the Wiki Page. Although the content is a little difficult to read it contains the HTML marker of Web Part added to content, which after decoding looks like this:</p>
<pre class="brush: xml;">&lt;div class=&quot;ms-rtestate-read ms-rte-wpbox&quot; contenteditable=&quot;false&quot;&gt;&lt;div class=&quot;ms-rtestate-notify  ms-rtestate-read 46113482-da36-45a5-bbac-e1e1771c19fa&quot; id=&quot;div_46113482-da36-45a5-bbac-e1e1771c19fa&quot;&gt;&lt;/div&gt;&lt;div id=&quot;vid_46113482-da36-45a5-bbac-e1e1771c19fa&quot; style=&quot;display: none&quot;&gt;&lt;/div&gt;&lt;/div&gt;</pre>
<p>Next, to the <em>AllUsersWebPart</em> tag we added the <em>ID</em> attribute (line 8). Although <a href="http://msdn.microsoft.com/en-us/library/ms446831.aspx?ocid=aff-n-we-loc--ITPRO40936&amp;WT.mc_id=aff-n-we-loc--ITPRO40936">the SDK doesn’t explain what this attribute is for</a>, it can be used to provision a Web Part with a predefined ID. The only requirement is, that all <strong>–</strong> (dash) are replaced with <strong>_</strong> (underscore) and the ID is prefixed with <strong>g_</strong>. As you can see the Web Part’s ID corresponds to the ID used in the marker placed in the Wiki Page’s content.</p>
<h3>Bonus: Declaratively Provisioning List View Web Parts to Wiki Pages</h3>
<p>There are scenarios when you might need to provision a List View Web Part to a Wiki Page. The good news is that the required approach is not much different from provisioning a Content Editor Web Part or any other Web Part for that matter.</p>
<p>If you’ve worked with declaratively provisioning List View Web Parts you know that in order to add a List View Web Part to a page you have to use the <strong>View</strong> element. For example to add a List View Web Part for the Announements list available in a standard Team Site to a Web Part Page, you would use the following code:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;
  &lt;Module Name=&quot;HomePage&quot;&gt;
    &lt;File Path=&quot;HomePage\default.aspx&quot; Url=&quot;default.aspx&quot;&gt;
      &lt;View List=&quot;$Resources:core,lists_Folder;/$Resources:core,announce_Folder;&quot; BaseViewID=&quot;1&quot; WebPartZoneID=&quot;Left&quot; WebPartOrder=&quot;0&quot; /&gt;
    &lt;/File&gt;
  &lt;/Module&gt;
&lt;/Elements&gt;</pre>
<p>Adding List View Web Parts to content is very similar to adding regular Web Parts. All you need to do is to change the value of the <em>WebPartZoneID</em> attribute to <strong>wpz<em> </em></strong>and add the <em>ID</em> attribute to the <em>View</em> element with a GUID specified exactly as if you would for any other Web Part that would be added in content, for example:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Elements xmlns=&quot;http://schemas.microsoft.com/sharepoint/&quot;&gt;
  &lt;Module Name=&quot;HomePage&quot;&gt;
    &lt;File Path=&quot;HomePage\wkpstd.aspx&quot; Url=&quot;SitePages/Home.aspx&quot;&gt;
      &lt;Property Name=&quot;WikiField&quot; Type=&quot;string&quot; Value=&quot;
&amp;lt;div class=&amp;quot;ms-rtestate-read ms-rte-wpbox&amp;quot; contentEditable=&amp;quot;false&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;ms-rtestate-read 46113482-da36-45a5-bbac-e1e1771c19fa&amp;quot; id=&amp;quot;div_46113482-da36-45a5-bbac-e1e1771c19fa&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;div style='display:none' id=&amp;quot;vid_46113482-da36-45a5-bbac-e1e1771c19fa&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;
      &quot;/&gt;
      &lt;View List=&quot;$Resources:core,lists_Folder;/$Resources:core,announce_Folder;&quot; BaseViewID=&quot;1&quot; WebPartZoneID=&quot;wpz&quot; WebPartOrder=&quot;4&quot; ID=&quot;g_46113482_da36_45a5_bbac_e1e1771c19fa&quot; /&gt;
    &lt;/File&gt;
&lt;/Module&gt;
&lt;/Elements&gt;</pre>
<p><a href="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/03.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The Announcements List View Web Part added to a Team Site" src="http://blog.mastykarz.nl/images/Provisioning-Web-Parts-to-Wiki-Pages-in-_6B7A/03_thumb.jpg" width="480" height="309" /></a></p>
<h2>Summary</h2>
<p>Sandboxed Solutions offer great power and flexibility for extending the SharePoint platform with custom functionality. The price of this empowerment is limited access to the SharePoint API and the .NET Framework. One of the common tasks which is affected is provisioning Web Part instances to pages. Although the programmatic approach is not available to SharePoint developers, the declarative way is a good alternative.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=rP34yvyikTE:RkgGV44JswY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=rP34yvyikTE:RkgGV44JswY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=rP34yvyikTE:RkgGV44JswY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=rP34yvyikTE:RkgGV44JswY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=rP34yvyikTE:RkgGV44JswY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=rP34yvyikTE:RkgGV44JswY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=rP34yvyikTE:RkgGV44JswY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/rP34yvyikTE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/</feedburner:origLink></item>
		<item>
		<title>Easier using widgets in SharePoint 2010 with the Mavention Widget Web Part</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/U_DXIMFha64/</link>
		<comments>http://blog.mastykarz.nl/easier-widgets-sharepoint-2010-mavention-widget-web-part/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 14:59:05 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Sandbox]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/easier-widgets-sharepoint-2010-mavention-widget-web-part/</guid>
		<description><![CDATA[In my previous article I explained why using widgets in SharePoint 2010 is inconvenient and showed what you can do to make it easier using the standard functionality. In this article I’ll show you how you can simplify working with widgets even further using the Mavention Widget Sandboxed Web Part. Mavention Widget Web Part The [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="twitter search widget displayed in the Widget Web Part" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/banner.jpg" width="471" height="110" />     <br /><a href="http://blog.mastykarz.nl/inconvenient-widgets-sharepoint-end-users/">In my previous article I explained why using widgets in SharePoint 2010 is inconvenient and showed what you can do to make it easier using the standard functionality</a>. In this article I’ll show you how you can simplify working with widgets even further using the Mavention Widget Sandboxed Web Part.</p>
<h2>Mavention Widget Web Part</h2>
<p>The Mavention Widget Web Part is a Sandboxed Web Part which allows you to include in the page any snippet of HTML without any restrictions. Although from the functionality point of view this Web Part doesn’t seem like much, it’s offering you a lot of flexibility and simplifies the maintenance of your pages.</p>
<p>In order to use the Mavention Widget Web Part you have to activate the Mavention Widget Web Parts Package first. Since it is a Sandboxed Solution you can do it by opening the <strong>Site Settings</strong> and navigating to the <strong>Solution Gallery</strong>.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/01.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="Link to the Solution Gallery highlighted on the Site Settings page" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/01_thumb.jpg" width="473" height="427" /></a></p>
<p>After uploading and activating the Mavention Widget Web Parts Package the Mavention Widget Web Parts Feature is installed. Because it’s a Site Collection-scoped Feature it is also automatically activated allowing you to directly start with including widgets on your pages.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/02.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="The Mavention Widget Web Parts Feature activated" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/02_thumb.jpg" width="480" height="58" /></a></p>
<p>After activating the Solution Package navigate to the page where you would like to insert a widget, edit the page and from the <strong>Insert</strong> tab click the <strong>Web Part</strong> button.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/03.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="The Insert Web Part button highlighted in the Ribbon" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/03_thumb.jpg" width="480" height="349" /></a></p>
<p>From the Categories list choose <strong>Mavention Web Parts</strong> (1), select the <strong>Widget Web Part</strong> (2) and click the <strong>Add</strong> button (3) to add the Web Part.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/04.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="Web Part Gallery opened on a page in SharePoint 2010" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/04_thumb.jpg" width="480" height="241" /></a></p>
<p>After adding the Web Part, edit its properties and from the <strong>Widget Web Part</strong> section click the <strong>Edit…</strong> button.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/05.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="The Edit Widget contents button highlighted in the Widget Web Part properties pane" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/05_thumb.jpg" width="480" height="212" /></a></p>
<p>Next, in the dialog window, paste the contents of your widget and confirm changes by clicking the <strong>OK</strong> button.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/06.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="twitter search widget pasted in the Widget Web Part" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/06_thumb.jpg" width="437" height="427" /></a></p>
<p>After you confirm changes the widget will appear in the Web Part.</p>
<p><a href="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/07.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="twitter search widget displayed in the Widget Web Part" src="http://blog.mastykarz.nl/images/08a78ee4d651_BF78/07_thumb.jpg" width="332" height="427" /></a></p>
<p>Editing the widget is just as easy as adding it. All you need to do is to open the Widget Web Part’s properties, click the <strong>Edit…</strong> button and you will see the widget’s code just as you pasted it.</p>
<p>Download: <a href="http://blog.mastykarz.nl/go/d-mavention_widgetwebparts/">Mavention Widget Web Part</a> (5KB, Sandboxed WSP)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=U_DXIMFha64:hr7DiEAlO_E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=U_DXIMFha64:hr7DiEAlO_E:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=U_DXIMFha64:hr7DiEAlO_E:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=U_DXIMFha64:hr7DiEAlO_E:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=U_DXIMFha64:hr7DiEAlO_E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=U_DXIMFha64:hr7DiEAlO_E:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=U_DXIMFha64:hr7DiEAlO_E:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/U_DXIMFha64" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/easier-widgets-sharepoint-2010-mavention-widget-web-part/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/easier-widgets-sharepoint-2010-mavention-widget-web-part/</feedburner:origLink></item>
		<item>
		<title>Inconvenient using widgets in SharePoint for end users</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/pLDrbpsk9Aw/</link>
		<comments>http://blog.mastykarz.nl/inconvenient-widgets-sharepoint-end-users/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 09:36:27 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Inconvenient SharePoint]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/inconvenient-widgets-sharepoint-end-users/</guid>
		<description><![CDATA[It’s a common approach to use widgets to enrich web solutions. Unfortunately using widgets with SharePoint 2010 has a number of challenges. Find out why using widgets with SharePoint is inconvenient and how you can simplify it. Widgets – they’re everywhere In the last few years many web services started providing widgets so that their [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="twitter search widget embedded in SharePoint using the Content Editor Web Part" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/banner.jpg" width="471" height="110" />     <br />It’s a common approach to use widgets to enrich web solutions. Unfortunately using widgets with SharePoint 2010 has a number of challenges. Find out why using widgets with SharePoint is inconvenient and how you can simplify it.</p>
<h2>Widgets – they’re everywhere</h2>
<p>In the last few years many web services started providing widgets so that their services can be integrated with websites. After all, who haven’t heard about the <a href="http://twitter.com/about/resources/widgets/widget_search">twitter search widget</a>, the <a href="http://developers.facebook.com/docs/reference/plugins/like/">facebook like button</a>, or about embedding a YouTube video in a page. The great thing about widgets is that they allow non-technical users to enrich their sites with dynamic functionality with nothing more than a few mouse clicks.</p>
<h2>Flexibility vs. security</h2>
<p>Many organizations that use SharePoint, no matter whether those are intranet portals on public-facing websites, want to be able to use widgets as well. Unfortunately when it comes to using widgets with SharePoint things aren’t as easy as you might have wanted them to be.</p>
<p>From the integration perspective, there are a number of ways in how you could integrate widgets into a SharePoint website. Although from the development point of view the integration capabilities are virtually limitless, it’s empowering the end users that many organizations are interested in. Assuming users have no permissions to modify Master Pages and Page Layouts, they can use widgets either by including them directly in content or by using the Content Editor Web Part.</p>
<p>Using scripts isn’t without risk. Considering how powerful client-side scripting is, when put in wrong hands, harmful scripts could cause damage. Not to mention that overusing widgets will very likely have a negative impact on the performance and can turn your website into a christmas tree. To protect users from all kinds of client-script attacks SharePoint has some protective precautions implemented.</p>
<h2>Using widgets in SharePoint 2010 for end users</h2>
<p>As a sample let’s try to use the twitter search widget.</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Sample twitter search widget" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/01.jpg" width="314" height="427" /></p>
<p>The twitter search widget uses the following code snippet that should be added to the page:</p>
<pre class="brush: xml;">&lt;script charset=&quot;utf-8&quot; src=&quot;http://widgets.twimg.com/j/2/widget.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: 'mavention',
  interval: 30000,
  title: 'Mavention',
  subject: 'What\'s new about Mavention',
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#5900be',
      color: '#ffffff'
    },
    tweets: {
      background: '#ffffff',
      color: '#444444',
      links: '#9c66d9'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    behavior: 'default'
  }
}).render().start();
&lt;/script&gt;</pre>
<h3>Using widgets in-line</h3>
<p>The first option to use widgets is to paste their HTML code directly in the page’s content. When you paste the widget’s code into a Publishing HTML field, everything seems to be okay at first.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/02.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="twitter widget’s code pasted into the HTML source of a Publishing HTML field" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/02_thumb.jpg" width="480" height="358" /></a></p>
<p>Although you will see the warning mentioning that the HTML source might have been modified, the widget’s code is still there just as you pasted it if you go back to the HTML source view.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/03.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Warning mentioning that the HTML source might have been modified" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/03_thumb.jpg" width="480" height="211" /></a></p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/04.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="twitter widget’s code in the HTML source of a Publishing HTML field" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/04_thumb.jpg" width="480" height="181" /></a></p>
<p>If you however save the page and once again open the HTML source you will see that all the widget code has been removed.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/05.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Empty HTML source window of a Publishing HTML field" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/05_thumb.jpg" width="480" height="171" /></a></p>
<h3>Using widgets with the Content Editor Web Part</h3>
<p>Another approach to use widgets with SharePoint that you might consider is by using the Content Editor Web Part (CEWP) and paste the widget’s contents there. Because the CEWP is not based on the Publishing HTML field, it shouldn’t theoretically have the same restrictions.</p>
<p>Let’s start off by adding a new Content Editor Web Part. It doesn’t really matter whether you insert it in content or in a Web Part Zone. Next, edit the Web Part’s content and paste the widget’s code into the CEWP’s HTML source.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/06.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="twitter widget’s code pasted into the HTML source of a Content Editor Web Part" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/06_thumb.jpg" width="480" height="197" /></a></p>
<p>Although, once again, you will see the warning about the HTML source being possibly modified, when you save the page the widget will appear on the page.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/07.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="twitter widget embedded on a page using the Content Editor Web Part" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/07_thumb.jpg" width="413" height="427" /></a></p>
<p>Imagine however, that at some point you wanted to change something about the widget. The moment you choose to edit the CEWP’s content, the widget will appear twice in the contents!</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/08.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="twitter widget displayed two times while editing the Content Editor Web Part" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/08_thumb.jpg" width="480" height="358" /></a></p>
<p>Although the widget doesn’t disappear, it’s almost impossible to modify it once added to the page. Every time you would need to change something about the widget you would have to reinsert it on the page.</p>
<blockquote>
<p>It’s worth noting that you won’t experience this behavior with all widgets. Embedding YouTube videos for example works okay, as the widget consists only of an iframe which is rendered properly within a Content Editor Web Part.</p>
</blockquote>
<h3>Using widgets with the Content Editor Web Part and external files</h3>
<p>Editing HTML directly in the Content Editor Web Part is not the only way to make it display some content. The CEWP also allows you to embed a piece of HTML from an external file. The great thing about it is that the CEWP doesn’t use iframe but embeds the HTML file directly in the page which is great for using widgets.</p>
<p>Embedding widgets by linking a Content Editor Web Part doesn’t introduce any limitations and works as you would expect it to, allowing you to embed all kinds of widgets in SharePoint pages.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/09.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="twitter search widget embedded by linking a Content Editor Web Part to an external file" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/09_thumb.jpg" width="480" height="268" /></a></p>
<p>The only downside of using this approach is that every widget has to be a separate file stored somewhere in your Site Collection. Unless you have a good strategy of how to keep track which file contains what widget, you can very easily loose track of them – especially if you’re using multiple different widgets across your site. Luckily SharePoint offers you a little help.</p>
<h3>Tracking usage of widget files</h3>
<p>You can track usage of your widget files within your Site Collection by using the Manage Content and Structure tool. For this, from the <strong>Site Actions</strong> menu choose the <strong>Manage Content and Structure </strong>option.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/10.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The Manage Content and Structure option highlighted in the Site Actions menu" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/10_thumb.jpg" width="230" height="427" /></a></p>
<p>Next, in the tree view select the Document Library that contains your widget files.</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Documents Library selected in the Manage Content and Structure tool" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/11.jpg" width="359" height="375" /></p>
<p>In the Documents View open the drop-down menu of the file for which you want to see where it’s being used on the Site Collection and choose the <strong>View Related Resources</strong> option.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/12.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The View Related Resources option highlighted in the context menu" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/12_thumb.jpg" width="480" height="383" /></a></p>
<p>After clicking the option, the Document View will split and the bottom part of the screen will contain a list of all the pages where the widget file is being used on.</p>
<p><a href="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/13.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="A list of pages using the twitter search widget" src="http://blog.mastykarz.nl/images/Easy-inserting-widgets-with-the-Maventio_E65F/13_thumb.jpg" width="480" height="358" /></a></p>
<h2>Summary</h2>
<p>Widgets can help you enrich your website and surface content from other sources. Unfortunately using widgets on SharePoint websites is not without challenges. Embedding widgets’ code in separate files and linking to them using the Content Editor Web Part is the only way available using the standard functionality to embed widgets on pages. To keep track of where which widgets are being used you can use the Manage Content and Structure tool provided with SharePoint. In the next article I will show you how you can embed widgets in pages using the Mavention Widgets Sandboxed Web Part if you find working with external files too inconvenient.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=pLDrbpsk9Aw:Pmh6bx9NqBQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=pLDrbpsk9Aw:Pmh6bx9NqBQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=pLDrbpsk9Aw:Pmh6bx9NqBQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=pLDrbpsk9Aw:Pmh6bx9NqBQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=pLDrbpsk9Aw:Pmh6bx9NqBQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=pLDrbpsk9Aw:Pmh6bx9NqBQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=pLDrbpsk9Aw:Pmh6bx9NqBQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/pLDrbpsk9Aw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/inconvenient-widgets-sharepoint-end-users/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/inconvenient-widgets-sharepoint-end-users/</feedburner:origLink></item>
		<item>
		<title>Better content targeting with Mavention Negated Audiences</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/RfzErBP8zO0/</link>
		<comments>http://blog.mastykarz.nl/content-targeting-mavention-negated-audiences/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 06:51:29 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/content-targeting-mavention-negated-audiences/</guid>
		<description><![CDATA[One of the frequent challenges when working with Audiences is the inability to provide alternative content to users outside the Audiences to which the content is targeted. Find out how to prevent pages from getting blank with Mavention Negated Audiences. SharePoint 2010 Audiences 101 The Audiences capability provided with SharePoint 2010 allows you to target [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="The &#39;Negate Audiences&#39; option selected in Web Part Properties Pane" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/banner.jpg" width="471" height="110" />     <br />One of the frequent challenges when working with Audiences is the inability to provide alternative content to users outside the Audiences to which the content is targeted. Find out how to prevent pages from getting blank with Mavention Negated Audiences.</p>
<h2>SharePoint 2010 Audiences 101</h2>
<p>The Audiences capability provided with SharePoint 2010 allows you to target content to specific groups of users. By leveraging Audiences you can not only unclutter the user interface but also make the solution more useful to the users by showing them relevant content.</p>
<p>Targeting content using Audiences in SharePoint 2010 is easy. Assuming you have configured Audiences in the User Profile Service Application, all you need to do is to navigate to a site, choose the Web Part that you want to display to specific audiences and in its properties select the desired Audiences.</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Managers’ Audience selected in Web Part’s properties" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/01.jpg" width="315" height="292" /></p>
<p>After you apply the changes and you navigate to that page as a user who is a member of the selected Audience, you should see the Web Part as intended.</p>
<p><a href="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/02.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Management Announcement’ Web Part displayed on the page" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/02_thumb.jpg" width="480" height="195" /></a></p>
<p>If you however navigate to the same page as a user who isn’t a part of the selected Audience, you won’t see the Web Part.</p>
<p><a href="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/03.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="A blank SharePoint 2010 Publishing Page" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/03_thumb.jpg" width="480" height="191" /></a></p>
<p>Although this works as intended, in many scenarios an empty spot or even a blank page is not good enough. In fact often content managers would like to be able to present alternative content to all users who are not a member of specific Audiences.</p>
<h2>Targeting content to everyone but the Audience</h2>
<p>One approach that you might consider for presenting alternative content to users who are not a part of specific Audiences is to create another Audience which contains all those users and target content to that Audience. This process can be challenging depending on the Audience rules: while it might be easy to create 18+ and 18- Audiences, you cannot really create an Audience with all users who don’t belong to a certain SharePoint group. Additionally this approach increases the solution maintenance effort as for every user group you have to maintain two Audiences instead of one.</p>
<p>Another approach worth considering is content targeting by negating the Audiences. Although it’s not available out of the box, it is a powerful approach that leverages the extensibility capabilities of the SharePoint 2010 platform. By extending the existing content targeting functionality, all you need to do is to add an option that allows you to negate the selection.</p>
<h2>Targeting content using Mavention Negated Audiences</h2>
<p>Mavention Negated Audiences is a SharePoint 2010 solution that extends the standard content targeting capabilities with negating audiences making it very easy to display alternative content to users who are not a member of specific Audiences.</p>
<p>Before you start targeting content using Mavention Negated Audiences, there is some configuration that needs to be done. Another thing that you should keep in mind is, that Mavention Negated Audiences extends the standard Audiences capability of SharePoint 2010. If you would like to stop using it at some point you would need to reconfigure all Web Parts where you used Negated Audiences (you checked the Negate Audiences checkbox). Considering there is not alternative functionality available out of the box you would very likely remove those Web Parts anyway.</p>
<h3>Prerequisites</h3>
<p>In order to use Mavention Negated Audiences you first need to install the Solution Package and deploy it in your Farm. Next, you have to select a Web Application where you want to use Mavention Negated Audiences, and enable the <em>Mavention Negated Audiences </em>Web Application Feature.</p>
<p><a href="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/04.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Mavention Negated Audiences’ Web Application Feature displayed in the list of Web Application Features" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/04_thumb.jpg" width="480" height="109" /></a></p>
<p>With that you can start targeting content to your users.</p>
<h3>Working with Mavention Negated Audiences</h3>
<p>Imagine you had a page where you would like to display one message to all managers and another to all other users. For this purpose you created the <em>Managers</em> Audience in the User Profile Service Application.</p>
<p>The first thing that we need to do is to add the message to managers to page and target it to the <strong>Managers</strong> Audience – just as we would do using the standard SharePoint 2010 Audiences functionality.</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Managers Announcement’ Web Part targeted to the Managers Audience" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/05.jpg" width="327" height="285" /></p>
<p>Next, let’s add another Web Part that will contain the alternative message that should be displayed to all users who are not managers. In the Audiences field choose once again the <strong>Managers</strong> Audience, but this time check the <strong>Negate Audiences</strong> checkbox as well.</p>
<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Non-Managers Announcement’ Web Part targeted to Managers with Negated Audience enabled" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/06.jpg" width="332" height="303" /></p>
<p>This will cause the Web Part to be displayed to all users who are not a member of the <em>Managers</em> Audience. Confirm your changes by clicking the <strong>OK</strong> button.</p>
<p>To test if everything is working correctly I have created two users: <em>Joris</em> (manager) and <em>Waldek</em> (employee). When I navigate to the announcement page as <em>Joris</em>, I will see the management announcement – as expected using the standard functionality.</p>
<p><a href="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/07.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The management announcement displayed to a user who is member of the Managers Audience" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/07_thumb.jpg" width="480" height="189" /></a></p>
<p>If I however navigate to the same page as <em>Waldek</em> I will see the alternative announcement!</p>
<p><a href="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/08.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The alternative announcement displayed to a user who is not a member of the Managers Audience" src="http://blog.mastykarz.nl/images/Better-content-targeting-with-Mavention-_F3BB/08_thumb.jpg" width="480" height="187" /></a></p>
<p>As you can see providing alternative content to users outside specific Audiences using Mavention Negated Audiences is very easy and adds minimal maintenance effort.</p>
<h2>Summary</h2>
<p>Using the Audiences capability of SharePoint 2010 you can target content to specific groups of users providing them with relevant content. One of the common limitation of the standard Audiences mechanism is the inability of providing alternative content to users who are not a member of the specific Audiences. With the Mavention Negated Audiences solution you can target content to both specific Audiences as well as all other users providing a complete experience to all your users.</p>
<p>Download: <a href="http://blog.mastykarz.nl/go/d-mavention_negatedaudiences/">Mavention Negated Audiences</a> (WSP, 6KB)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=RfzErBP8zO0:_R5puXTRXic:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=RfzErBP8zO0:_R5puXTRXic:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=RfzErBP8zO0:_R5puXTRXic:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=RfzErBP8zO0:_R5puXTRXic:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=RfzErBP8zO0:_R5puXTRXic:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=RfzErBP8zO0:_R5puXTRXic:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=RfzErBP8zO0:_R5puXTRXic:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/RfzErBP8zO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/content-targeting-mavention-negated-audiences/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/content-targeting-mavention-negated-audiences/</feedburner:origLink></item>
		<item>
		<title>Granting permissions to the User Profile Service Application using PowerShell</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/u0VrJZDkvbk/</link>
		<comments>http://blog.mastykarz.nl/granting-permissions-user-profile-service-application-powershell/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 14:12:16 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Structured and repeatable deployment]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/granting-permissions-user-profile-service-application-powershell/</guid>
		<description><![CDATA[In my previous article I explained how access permissions to the User Profile Service Application are required if you want to programmatically configure Navigation of a Publishing Site in SharePoint 2010. In the article I showed you how you can configure grant required permissions manually. There are however scenarios when you might need to configure [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="The &#39;Connection Permissions for User Profile Service Application&#39; modal window displayed in Central Administration" src="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/banner.jpg" width="471" height="110" />     <br /><a href="/programmatically-configuring-menu-items-sharepoint-2010-revisited/">In my previous article I explained how access permissions to the User Profile Service Application are required if you want to programmatically configure Navigation of a Publishing Site in SharePoint 2010</a>. In the article I showed you how you can configure grant required permissions manually. There are however scenarios when you might need to configure those permissions in a structured and repeatable way. Find out how to grant permissions to the User Profile Service Application using PowerShell.</p>
<h2>It’s all about having access</h2>
<p>Previously I showed you how to avoid an exception being throw while configuring Navigation for a Publishing Site in SharePoint 2010. Because Navigation configuration requires internally the access to Audiences information, the account that you are using to execute the navigation configuration PowerShell script has to have sufficient permissions to access the User Profile Service Application where the Audiences information is stored.</p>
<p>As I explained previously you can configure those permissions by navigating to <strong>Central Administration</strong> and from the <strong>Application Management</strong> group clicking the <strong>Manage service applications</strong> link.</p>
<p><a href="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/01.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="The ‘Manage service applications’ link highlighted in Central Administration" src="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/01_thumb.jpg" width="480" height="298" /></a></p>
<p>Next, from the list of available Service Applications, select the <strong>User Profile Service Application</strong> and in the Ribbon, from the <strong>Sharing</strong> group, click the <strong>Permissions</strong> button.</p>
<p><a href="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/02.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="The &#39;Permissions&#39; button highlighted in the Ribbon" src="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/02_thumb.jpg" width="480" height="322" /></a></p>
<p>Add the account that you are using to execute the navigation configuration PowerShell script (1) and give it <strong>Full Control</strong> permissions (2). Confirm your changes by clicking the <strong>OK</strong> button (3).</p>
<p><a href="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/03.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="Granting permissions to access the User Profile Service Application to the administrator account" src="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/03_thumb.jpg" width="407" height="427" /></a></p>
<p>The interesting part is, that if you go back to the Permissions screen, you will see that the permissions to the User Profile Service Application are granted to an identity claim generated using the previously provided account and not the user object itself.</p>
<p><a href="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/04.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="User Profile Service Application Permission screen showing an identity claim" src="http://blog.mastykarz.nl/images/ed22c934fc02_CD46/04_thumb.jpg" width="403" height="427" /></a></p>
<p>This is an important detail that we have to take into account while building the PowerShell script.</p>
<h2>Configuring User Profile Service Application permissions using PowerShell</h2>
<p>You can configure User Profile Service Application permissions using the following PowerShell script:</p>
<pre class="brush: ps;" title="Set-UpsConnectionPermission.ps1">param (
    $accountName
)

$claimType = &quot;http://schemas.microsoft.com/sharepoint/2009/08/claims/userlogonname&quot;
$claimValue = $accountName
$claim = New-Object Microsoft.SharePoint.Administration.Claims.SPClaim($claimType, $claimValue, &quot;http://www.w3.org/2001/XMLSchema#string&quot;, [Microsoft.SharePoint.Administration.Claims.SPOriginalIssuers]::Format(&quot;Windows&quot;))
$claim.ToEncodedString()

$permission = [Microsoft.SharePoint.Administration.AccessControl.SPIisWebServiceApplicationRights]&quot;FullControl&quot;

$SPAclAccessRule = [Type]&quot;Microsoft.SharePoint.Administration.AccessControl.SPAclAccessRule``1&quot;
$specificSPAclAccessRule = $SPAclAccessRule.MakeGenericType([Type]&quot;Microsoft.SharePoint.Administration.AccessControl.SPIisWebServiceApplicationRights&quot;)
$ctor = $SpecificSPAclAccessRule.GetConstructor(@([Type]&quot;Microsoft.SharePoint.Administration.Claims.SPClaim&quot;,[Type]&quot;Microsoft.SharePoint.Administration.AccessControl.SPIisWebServiceApplicationRights&quot;))
$accessRule = $ctor.Invoke(@([Microsoft.SharePoint.Administration.Claims.SPClaim]$claim, $permission))

$ups = Get-SPServiceApplication | ? { $_.TypeName -eq 'User Profile Service Application' }
$accessControl = $ups.GetAccessControl()
$accessControl.AddAccessRule($accessRule)
$ups.SetAccessControl($accessControl)
$ups.Update()</pre>
<p>First we generate the identity claim using the account name for which we want to grant access permissions (lines 5-8). Next we generate an access rule for the identity claim and the <em>FullControl</em> permission (lines 12-15). Finally we retrieve the User Profile Service Application (line 17) and we add the newly created access rule (lines 18 and 19). To persist the changes we have to replace the existing <em>AccessControl</em> object with the new one by calling the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spiiswebserviceapplication.setaccesscontrol.aspx?ocid=aff-n-we-loc--ITPRO40936&amp;WT.mc_id=aff-n-we-loc--ITPRO40936">SPIisWebServiceApplication.SetAccessControl</a> method (line 20) and update the User Profile Service Application object (line 21).</p>
<p>If you for example would like to grant access to the User Profile Service Application to the <em>win2008\administrator</em> account, you would execute the PowerShell script as follows:</p>
<pre class="brush: ps;">.\Set-UpsConnectionPermission.ps1 &quot;win2008\administrator&quot;</pre>
<p>This would grant the access permissions to the <em>win2008\administrator</em> account required to programmatically configure Navigation of a Publishing Site in SharePoint 2010.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=u0VrJZDkvbk:zVfUHw5Js8k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=u0VrJZDkvbk:zVfUHw5Js8k:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=u0VrJZDkvbk:zVfUHw5Js8k:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=u0VrJZDkvbk:zVfUHw5Js8k:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=u0VrJZDkvbk:zVfUHw5Js8k:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=u0VrJZDkvbk:zVfUHw5Js8k:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=u0VrJZDkvbk:zVfUHw5Js8k:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/u0VrJZDkvbk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/granting-permissions-user-profile-service-application-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/granting-permissions-user-profile-service-application-powershell/</feedburner:origLink></item>
		<item>
		<title>Programmatically configuring menu items in SharePoint 2010 revisited</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/0AA1IhBIqyY/</link>
		<comments>http://blog.mastykarz.nl/programmatically-configuring-menu-items-sharepoint-2010-revisited/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 09:51:54 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Structured and repeatable deployment]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/programmatically-configuring-menu-items-sharepoint-2010-revisited/</guid>
		<description><![CDATA[A while ago I wrote about how you can programmatically configure menu items in SharePoint 2010 using PowerShell. Unfortunately it turns out that it doesn’t always the way you would expect it to. Find out how to get the script working in your SharePoint environment. Being able to programmatically configure menu items is an quite [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="Exception displayed in a PowerShell window" src="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/banner.jpg" width="471" height="110" />     <br />A while ago I wrote about how you can programmatically configure menu items in SharePoint 2010 using PowerShell. Unfortunately it turns out that it doesn’t always the way you would expect it to. Find out how to get the script working in your SharePoint environment.</p>
<p>Being able to programmatically configure menu items is an quite important part of structured and repeatable deployment. Particularly if you’re building and deploying frequently, configuring navigation can save you quite some time and make it easier for you to run automated tests.</p>
<p><a href="/programmatically-configuring-menu-items-sharepoint-2010/">Back in June I shared with you a PowerShell script that allowed you to automatically configure navigation on a Publishing Site built on the SharePoint 2010 platform</a>. While that script worked on my development machine, at some point I started receiving some error reports about it failing in other environments. Every time you would execute the script you would get the following error:</p>
<blockquote><p>Exception calling &quot;GetNavigationChildren&quot; with &quot;6&quot; argument(s): &quot;Object reference not set to an instance of an object.&quot;</p>
</blockquote>
<p><a href="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/01.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="An exception displayed in a PowerShell window" src="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/01_thumb.jpg" width="480" height="180" /></a></p>
<p>As you might have expected, the navigation would remain in its original state.</p>
<h2>What is wrong and how to fix it</h2>
<p>It turns out that while working with Navigation SharePoint also requests Audiences information. This is not that surprising considering that SharePoint allows you to target navigation item to audiences.</p>
<p>The exception I have just showed you is being thrown because the account that you are using to run the PowerShell script is not allowed to access Audiences information from the User Profile Service Application.</p>
<p>To solve this issue, you have to grant your account permission to access the User Profile Service Application. You can do this by navigating to <strong>Central Administration</strong> and from the <strong>Application Management</strong> group clicking the <strong>Manage service applications</strong> link.</p>
<p><a href="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/02.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Manage service applications’ link highlighted in Central Administration" src="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/02_thumb.jpg" width="480" height="298" /></a></p>
<p>Next, from the list of available Service Applications, select the <strong>User Profile Service Application</strong> and in the Ribbon, from the <strong>Sharing</strong> group, click the <strong>Permissions</strong> button.</p>
<p><a href="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/03.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="03" border="0" alt="03" src="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/03_thumb.jpg" width="480" height="322" /></a></p>
<p>Add the account that you are using to execute the navigation configuration PowerShell script (1) and give it <strong>Full Control</strong> permissions (2). Confirm your changes by clicking the <strong>OK</strong> button (3).</p>
<p><a href="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/04.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Granting permissions to access the User Profile Service Application to the administrator account" src="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/04_thumb.jpg" width="407" height="427" /></a></p>
<p>If you execute the script now, you should see it working as expected.</p>
<p><a href="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/05.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="Navigation configuration PowerShell script successfully completed" src="http://blog.mastykarz.nl/images/Programmatically-configuring-menu-items-_760A/05_thumb.jpg" width="480" height="277" /></a></p>
<h2>One more thing</h2>
<p>Once in a while the navigation configuration script throws another exception when retrieving navigation nodes. This happens when the Application Pool haven’t been warmed up and the information about navigation nodes has not been made available yet. To avoid this error I have extended the script with a call to the home page of the site, to start the Application Pool and ensure that all the information is in place before we start working with it.</p>
<pre class="brush: ps;">Write-Host &quot;Warming up site $($WebUrl)...&quot; -NoNewline
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
$wc.DownloadString($WebUrl) | Out-Null
Write-Host &quot;DONE&quot; -ForegroundColor Green</pre>
<p>The updated version of the script looks as follows:</p>
<pre class="brush: ps;">param (
    $SiteUrl = &quot;http://publishing&quot;
)

function Set-Navigation {
    param (
        $WebUrl,
        $MenuItems
    )

    Write-Host &quot;Warming up site $($WebUrl)...&quot; -NoNewline
    $wc = New-Object System.Net.WebClient
    $wc.UseDefaultCredentials = $true
    $wc.DownloadString($WebUrl) | Out-Null
    Write-Host &quot;DONE&quot; -ForegroundColor Green

    $site = New-Object Microsoft.SharePoint.SPSite($WebUrl)
    $web = $site.OpenWeb()

    # fake context
    [System.Web.HttpRequest] $request = New-Object System.Web.HttpRequest(&quot;&quot;, $web.Url, &quot;&quot;)
    $sw = New-Object System.IO.StringWriter
    $hr = New-Object System.Web.HttpResponse($sw)
    [System.Web.HttpContext]::Current = New-Object System.Web.HttpContext($request, $hr)
    [Microsoft.SharePoint.WebControls.SPControl]::SetContextWeb([System.Web.HttpContext]::Current, $web)

    # initalize what has to be initialized
    $pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
    $dictionary = New-Object &quot;System.Collections.Generic.Dictionary``2[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Microsoft.SharePoint.Navigation.SPNavigationNode, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]]&quot;
    $collection = $pweb.Navigation.GlobalNavigationNodes

    # get current nodes
    $globalNavSettings = New-Object System.Configuration.ProviderSettings(&quot;GlobalNavSiteMapProvider&quot;, &quot;Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot;)
    $globalNavSettings.Parameters[&quot;NavigationType&quot;] = &quot;Global&quot;
    $globalNavSettings.Parameters[&quot;EncodeOutput&quot;] = &quot;true&quot;
    [Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider] $globalNavSiteMapProvider = [System.Web.Configuration.ProvidersHelper]::InstantiateProvider($globalNavSettings, [type]&quot;Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider&quot;)
    [Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode] $currentNode = $globalNavSiteMapProvider.CurrentNode
    $children = $currentNode.GetNavigationChildren([Microsoft.SharePoint.Publishing.NodeTypes]::Default, [Microsoft.SharePoint.Publishing.NodeTypes]::Default, [Microsoft.SharePoint.Publishing.OrderingMethod]::Manual, [Microsoft.SharePoint.Publishing.AutomaticSortingMethod]::Title, $true, -1);

    # reorder nodes
    [Array]::Reverse($menuItems)
    $menuNodes = New-Object System.Collections.ObjectModel.Collection[Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode]
    foreach ($node in $children) {
        $menuNodes.Add($node)
    }

    foreach ($menuItem in $menuItems) {
        $node = $null
        foreach ($p in $menuNodes) {
            if ($p.InternalUrl -eq $menuItem) {
                $node = $p
                break
            }
        }

        if ($node -ne $null) {
            [void] $menuNodes.Remove($node)
            [Void] $menuNodes.Insert(0, $node)
        }
    }

    foreach ($node in $menuNodes) {
        Write-Host &quot;$($node.InternalUrl)...&quot; -NoNewline
        $quickId = Get-QuickId $node
        if ($quickId -ne $null -and $quickId.Length -gt 0) {
            [string]$typeId = $null;
            if (($node.Type -eq [Microsoft.SharePoint.Publishing.NodeTypes]::Area) -or ($node.Type -eq [Microsoft.SharePoint.Publishing.NodeTypes]::Page)) {
                if ($node.PortalProvider.NavigationType -eq [Microsoft.SharePoint.Publishing.Navigation.PortalNavigationType]::Current) {
                    $typeId = [Microsoft.SharePoint.Publishing.Navigation.PortalNavigationType]::Current.ToString() + &quot;_&quot; + $node.Type.ToString()
                }
                else {
                    $typeId = [Microsoft.SharePoint.Publishing.Navigation.PortalNavigationType]::Global.ToString() + &quot;_&quot; + $node.Type.ToString()
                }
            }
            else {
                $typeId = $node.Type.ToString();
            }

            $id = $quickId.Split(',');
            $objId = New-Object Guid($id[0]);
            $nodeId = [System.Int32]::Parse($id[1]);

            $navigationNode = Get-NavigationNode $objId $nodeId $node.InternalTitle $node.InternalUrl $node.Description $node.Type $node.Target $node.Audience $collection $dictionary
            $containsNode = $false
            foreach ($mi in $menuItems) {
                if ($mi -eq $node.InternalUrl) {
                    $containsNode = $true
                    break
                }
            }

            if ($containsNode) {
                $pweb.Navigation.IncludeInNavigation($true, $objId)
            }
            else {
                $pweb.Navigation.ExcludeFromNavigation($true, $objId)
            }

            Write-Host &quot;DONE&quot; -ForegroundColor Green
        }
        else {
            Write-Host &quot;SKIPPED&quot; -ForegroundColor Yellow
        }
    }

    $pweb.Web.Update()

    [System.Web.HttpContext]::Current = $null
}

function Get-QuickId {
    param (
        [Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode] $node
    )

    $quickId = $null

    $portalSiteMapNodeType = $node.GetType()
    $QuickId = $portalSiteMapNodeType.GetProperty(&quot;QuickId&quot;, [System.Reflection.BindingFlags] &quot;Instance, NonPublic&quot;)
    $quickId = [string] $QuickId.GetValue($node, $null)

    $quickId
}

function Get-NavigationNode {
    param (
        [Guid] $objId,
        [int] $nodeId,
        [string] $name,
        [string] $url,
        [string] $description,
        [Microsoft.SharePoint.Publishing.NodeTypes] $nodeType,
        [string] $target,
        [string] $audience,
        [Microsoft.SharePoint.Navigation.SPNavigationNodeCollection] $collection,
        $oldDictionary
    )

    [Microsoft.SharePoint.Navigation.SPNavigationNode] $node = $null
    if (($objId -ne [Guid]::Empty) -and ($nodeId -ge 0)) {
        if ($oldDictionary.TryGetValue($nodeId, [ref]$node)) {
            $oldDictionary.Remove($nodeId)
            $node = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::UpdateSPNavigationNode($node.Navigation.GetNodeById($node.Id), $null, $name, $url, $description, $target, $audience, $false)
            $node.MoveToLast($collection)
        }

        return $node;
    }

    $node = [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::CreateSPNavigationNode($name, $url, $nodeType, $collection);
    return [Microsoft.SharePoint.Publishing.Navigation.SPNavigationSiteMapNode]::UpdateSPNavigationNode($node, $null, $name, $node.Url, $description, $target, $audience, $false);
}

Write-Host &quot;Configuring Navigation...&quot;
$menuItems = &quot;/site1&quot;, &quot;/site2&quot;, &quot;/site3&quot;, &quot;/site4&quot;, &quot;/site5&quot;, &quot;/site5&quot;
Set-Navigation $SiteUrl $menuItems
Write-Host &quot;Navigation Configuration completed&quot; -ForegroundColor Green</pre>
<h2>Summary</h2>
<p>Configuring navigation as a part of structured and repeatable deployment can save you time and help you automate the testing process. In order to configure navigation on Publishing Sites in SharePoint 2010 the account that executes the configuration script must be granted access to the User Profile Service Application which contains information about Audiences which is used by SharePoint 2010 to target navigation items to specific groups of users.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0AA1IhBIqyY:rfM2gvJ-NNU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0AA1IhBIqyY:rfM2gvJ-NNU:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0AA1IhBIqyY:rfM2gvJ-NNU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=0AA1IhBIqyY:rfM2gvJ-NNU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0AA1IhBIqyY:rfM2gvJ-NNU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0AA1IhBIqyY:rfM2gvJ-NNU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=0AA1IhBIqyY:rfM2gvJ-NNU:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/0AA1IhBIqyY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/programmatically-configuring-menu-items-sharepoint-2010-revisited/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/programmatically-configuring-menu-items-sharepoint-2010-revisited/</feedburner:origLink></item>
		<item>
		<title>Why automatic creation of variation sites and pages can be harmful</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/Ep_Hg1QZTdY/</link>
		<comments>http://blog.mastykarz.nl/automatic-creation-variation-sites-pages-harmful/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 09:27:45 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[WCM]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/automatic-creation-variation-sites-pages-harmful/</guid>
		<description><![CDATA[When working with Variations, using the option to automatically create variation pages is very tempting. Unfortunately, if used improperly, it can have negative impact on the search ranking of your website. Variations as approach for supporting multilingual sites A common approach to implement multilingual solutions on the Microsoft SharePoint 2010 platform is to use Variations. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="The &#39;Automatically create site and page variations&#39; option selected" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/banner.jpg" width="471" height="110" />     <br />When working with Variations, using the option to automatically create variation pages is very tempting. Unfortunately, if used improperly, it can have negative impact on the search ranking of your website.</p>
<h2>Variations as approach for supporting multilingual sites</h2>
<p>A common approach to implement multilingual solutions on the Microsoft SharePoint 2010 platform is to use Variations. Although Variations can be used for other purposes as well, delivering content in multiple languages is probably the most common usage scenario.</p>
<p>Before you start working with Variations you have to configure how you want them work. There are a few options to set such as whether you want to copy resources or reuse them from a centralized location. All the necessary settings can be controlled from the <strong>Variation Settings</strong> page.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/01.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The Variation Settings page in SharePoint 2010" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/01_thumb.jpg" width="456" height="427" /></a></p>
<p>One of the options that you can configure is <em>Automatic Creation</em> of variation pages.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/02.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The Automatic Creation option highlighted in the Variation Settings page" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/02_thumb.jpg" width="480" height="101" /></a></p>
<p>By configuring this option to <strong>Automatically create site and page variations</strong> every time you create a site or publish a page, draft versions in all defined variations will be created automatically. And this is when things may go wrong.</p>
<h2>Why automatically creating variation pages may be harmful</h2>
<p>If you’re using Variations to deliver content to multiple devices you will very likely be okay and using the automatic variation pages creation will do you no harm. It’s using Variations for delivering multilingual content to users that deserves additional consideration.</p>
<p>The way automatic variation pages creation works is that every time you create a site, a site with the same name (URL) will be created in all variation labels. Comparably, every time you publish a page, a draft version of that page will be created in all variation labels. The problem is that the created sites and pages will have <strong>exactly the same URL</strong> as the site/page in the source label and the only difference will be the variation label’s name. To illustrate this problem let’s take a look at the following example.</p>
<h3>An example of how things go wrong</h3>
<p>Let’s say we had a website with an <em>About Us</em> section and within it a <em>Careers</em> page with an overview of all the job offers. Assuming the English variation label is the source label, the Careers page could have the following URL:</p>
<p><strong>/en/about-us/pages/careers.aspx</strong></p>
<p>An English-speaking person searching for careers would have a hit on the <em>careers</em> word in the URL what would cause the page rank relatively high in the search results.</p>
<p>If we used automatic variation pages creation, after publishing the English Careers page, the variations engine would create a draft in the Dutch label using the following URL:</p>
<p><strong>/nl/about-us/pages/careers.aspx</strong></p>
<blockquote><p><strong>Important: </strong>Because creating variations sites and pages in SharePoint 2010 is being done using Timer Jobs it can take a moment for them to be created.</p>
</blockquote>
<p>And although most content editors edit the site’s/page’s title, the URLs remain unchanged.</p>
<p>Even if you don’t speak Dutch, you can imagine that neither <em>about-us</em> nor <em>careers</em> mean anything in Dutch. With that in mind, the odds are high that a Dutch-speaking person would be less likely to find our Careers page when looking for job offers in Dutch (<em>vacatures</em>).</p>
<p>As you can see, because the URL is one of the most important metrics for determining the ranking of pages in search results using automatic variation pages and sites creation is very bad for your website! Not only it makes the content more difficult to find but it also make the URLs more difficult to understand.</p>
<p>If you’re using automatic variation pages creation, you can still change the URL after the draft version has been created. But why not consider creation variation pages manually and prevent problems from occurring in the first place?</p>
<h2>Manually creating variation sites and pages</h2>
<p>The process of manually creating variations sites and pages begins with configuring the <em>Automatic Creation</em> option in the <em>Variations Settings </em>page to <strong>Do not automatically create site and page variations</strong>. This can be done before you create variation hierarchies as well as after you have created them.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/03.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘Automatic Creation’ setting configured to ‘Do not automatically create site and page variations’" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/03_thumb.jpg" width="480" height="103" /></a></p>
<p>The next time you create a site or publish a page only that particular site/page will be created. You will have to create the variation sites and pages in all variations yourself. While this might seem tedious, it allows you to explicitly define the URLs of the created sites and pages right from the beginning.</p>
<h3>Creating variation pages</h3>
<p>Creating variation pages is very simple and can be done using the Ribbon. To create a variation for a page navigate to that page and in the Ribbon activate the <strong>Publishing</strong> tab. Next, from the <strong>Variations</strong> group click the <strong>Create</strong> button.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/04.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The Create Variation button highlighted in the Ribbon" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/04_thumb.jpg" width="480" height="381" /></a></p>
<blockquote><p><strong>Important: </strong>For the Create Variation button to be active the page that you want to create variation for has to have at least one minor version created.</p>
</blockquote>
<p>After that you will see the <em>New Page Variation</em> page where you can provide the Title and the URL of the variation page, select the Page Layout that you want to use and choose the variation label in which you want this page to be created.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/05.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘New Page Variation’ page" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/05_thumb.jpg" width="456" height="427" /></a></p>
<p>After you click the <strong>Create</strong> button, a new variation page will be created.</p>
<h3>Creating variation sites</h3>
<p>Comparing to creating page variations, creating site variations is a little less convenient. If you look in the Ribbon or on the Site Settings page, you won’t find any option there that would allow you to create a site variation.</p>
<p>Using the standard SharePoint 2010 functionality creating site variations is possible only using the <em>Manage Content and Structure</em> tool. To create a site variation, from the <strong>Site Actions</strong> menu click the <strong>Manage Content and Structure</strong> option. Next, open the context menu for a site for which you want to create variation and select the <strong>New &gt; Site Variation</strong> option.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/06.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘New Site Variation’ option highlighted in the Manage Content and Structure tool" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/06_thumb.jpg" width="402" height="427" /></a></p>
<p>You will be redirected to the <em>New Variation Site</em> page where you will be able to select the variation label in which you want to create the site variation and you will be able to provide the Title and the URL of the variation site.</p>
<p><a href="http://blog.mastykarz.nl/images/135cf0eed54a_643F/07.jpg"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="" border="0" alt="The ‘New Variation Site’ page" src="http://blog.mastykarz.nl/images/135cf0eed54a_643F/07_thumb.jpg" width="480" height="306" /></a></p>
<p>After you click the <strong>OK</strong> button, the variation site will be created.</p>
<blockquote><p><strong>Important:</strong> Similarly to page variations, site variations are created using Timer Jobs so it might take a moment before you will be able to open the site variation that you have just created.</p>
</blockquote>
<p>As you can see, because you are creating pages and sites variations manually, you have to explicitly provide the name (URL) for the site/page in the given language. With that there is much more chance that sites and pages will be created in the language related to the specific variation label.</p>
<h2>Summary</h2>
<p>When working with multilingual websites, SharePoint 2010 offers the Variations capability to support managing content in all the different languages. When working with Variations many content managers choose to use automatic site and page variation creation. The downside of this approach is that URLs on which the sites and pages are created don’t reflect the specific variation language. Although it is not impossible to change the URLs afterwards, it might be worth considering to change the variation creation process to manual and to help content managers think about translating the URL to optimize the content for search engines.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=Ep_Hg1QZTdY:_EpKb4sQfb8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=Ep_Hg1QZTdY:_EpKb4sQfb8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=Ep_Hg1QZTdY:_EpKb4sQfb8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=Ep_Hg1QZTdY:_EpKb4sQfb8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=Ep_Hg1QZTdY:_EpKb4sQfb8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=Ep_Hg1QZTdY:_EpKb4sQfb8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=Ep_Hg1QZTdY:_EpKb4sQfb8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/Ep_Hg1QZTdY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/automatic-creation-variation-sites-pages-harmful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/automatic-creation-variation-sites-pages-harmful/</feedburner:origLink></item>
		<item>
		<title>Correctly implementing Ribbon in SharePoint 2010</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/qIjkMCXsGfM/</link>
		<comments>http://blog.mastykarz.nl/correctly-implementing-ribbon-sharepoint-2010/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 11:02:57 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Customization]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Ribbon]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/correctly-implementing-ribbon-sharepoint-2010/</guid>
		<description><![CDATA[SharePoint 2010 introduces a new User Experience designed to make it easier for users to accomplish their tasks. One of the biggest improvements is the contextual Ribbon, which increases discoverability op options by displaying only options relevant to the current context. The main idea behind the Ribbon is that it’s always available and within reach. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="Ribbon in SharePoint 2010" src="http://blog.mastykarz.nl/images/1ba15ddde197_6DED/banner.jpg" width="471" height="110" />     <br />SharePoint 2010 introduces a new User Experience designed to make it easier for users to accomplish their tasks. One of the biggest improvements is the contextual Ribbon, which increases discoverability op options by displaying only options relevant to the current context. The main idea behind the Ribbon is that it’s always available and within reach. This applies not only to Office client applications but also to SharePoint.</p>
<h2>Positioning the Ribbon</h2>
<p>Following Microsoft’s guidelines, the Ribbon should always float at the top of the page. And although SharePoint 2010 provides us with a mechanism to position the Ribbon correctly, there is some work that needs to be done by us as well.</p>
<p>When creating new Master Pages, you will be very likely using either the <a href="http://startermasterpages.codeplex.com/">Starter Master Pages for SharePoint 2010</a>, made by fellow SharePoint MVP – <a href="http://blog.drisgill.com/">Randy Drisgill</a>, or one of the standard SharePoint Master Pages as a starting point. No matter your preference, in both cases you will be provided with all the necessary components to get the Ribbon positioned correctly. It’s upgrading existing SharePoint 2007 Master Pages that requires extra attention to ensure that you get all the necessary components in place.</p>
<h2>How they do it: Floating Ribbon</h2>
<p>SharePoint 2010 uses a rather complex approach to make the Ribbon float on the top of the page. On every page load, page’s height is being measured using JavaScript and the Ribbon and body are sized using those dimension. In order for this process to be executed SharePoint requires your Master Page to contain elements with the following ID’s: <strong>s4-ribbonrow</strong>, <strong>s4-workspace</strong> and <strong>s4-bodyContainer</strong>. If you haven’t defined one of those ID’s, the Ribbon positioning logic will <strong>not be executed</strong>.</p>
<p>The logic behind positioning the Ribbon is implemented in the <em>init.js</em> file in the <em>FixRibbonAndWorkspaceDimensions</em><strong> </strong>function (line 3406; the exact position may depend on your patching level). In lines 3409-3412 how different prerequisite elements are being retrieved and how SharePoint checks in line 3413-3415 if all the required elements have been defined.</p>
<p><a href="http://blog.mastykarz.nl/images/1ba15ddde197_6DED/01.jpg"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="The Fix Ribbon And Workspace Dimensions function highlighted in Visual Studio" src="http://blog.mastykarz.nl/images/1ba15ddde197_6DED/01_thumb.jpg" width="480" height="371" /></a></p>
<p>So whenever you have problems getting the Ribbon positioning to work, don’t forget to check if you have all those ID’s defined properly in your Master Page. Using standard Master Pages such as <em>v4.master</em> or <em>nightandday.master</em> is always a good idea to verify that you have done everything correctly.</p>
<h2>Summary</h2>
<p>SharePoint 2010 introduces the Ribbon to make it easier for users to accomplish their tasks. One of the ideas behind the Ribbon is that it’s always within the reach so that users can easily discover functionality they need at the given moment. Correctly laying out the Ribbon can be achieved using the standard SharePoint 2010 functionality but requires placing specific elements to get it to work.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=qIjkMCXsGfM:i8RvUm8_nSE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=qIjkMCXsGfM:i8RvUm8_nSE:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=qIjkMCXsGfM:i8RvUm8_nSE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=qIjkMCXsGfM:i8RvUm8_nSE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=qIjkMCXsGfM:i8RvUm8_nSE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=qIjkMCXsGfM:i8RvUm8_nSE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=qIjkMCXsGfM:i8RvUm8_nSE:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/qIjkMCXsGfM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/correctly-implementing-ribbon-sharepoint-2010/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/correctly-implementing-ribbon-sharepoint-2010/</feedburner:origLink></item>
		<item>
		<title>Microsoft SharePoint 2010 Development Cookbook–book review</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/XYtyqOreDaY/</link>
		<comments>http://blog.mastykarz.nl/microsoft-sharepoint-2010-development-cookbook-book-review/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 12:38:36 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[SharePoint 2010]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/microsoft-sharepoint-2010-development-cookbook-book-review/</guid>
		<description><![CDATA[Recently I had the opportunity of reviewing a brand new book for SharePoint developers – the Microsoft SharePoint 2010 Development Cookbook written by fellow SharePoint MVP Ed Musters. What I expected Following the title I expected a cookbook: a collection of recipes that illustrate common good practices in developing SharePoint solutions. There are many books [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro-banner" alt="Book cover" src="http://blog.mastykarz.nl/images/Microsoft-SharePoint-2010-Development-Co_6C52/banner.jpg" width="471" height="110" />    <br />Recently I had the opportunity of reviewing a brand new book for SharePoint developers – the <a href="https://www.packtpub.com/microsoft-sharepoint-2010-development-from-beginner-to-professional-cookbook/book">Microsoft SharePoint 2010 Development Cookbook</a> written by fellow SharePoint MVP Ed Musters.</p>
<h2>What I expected</h2>
<p>Following the title I expected a cookbook: a collection of recipes that illustrate common good practices in developing SharePoint solutions. There are many books about development on the SharePoint platform so I expected this cookbook to be different and offer the reader some added value. An idea of having recipes that you can browse whenever you don’t need all the explanation but just need an overview of steps to follow to get things done seems very appealing to me.</p>
<p>Considered the audience (experienced ASP.NET developers) I expected to see a mix of basic and complex recipes that demonstrate how different things can be achieved in SharePoint.</p>
<h2>What I got</h2>
<p>The first recipe in Ed’s book presents how to create a development environment. If you’ve been working with SharePoint already, it might not be the most interesting part of the book, but you should definitely read it, if you are new to developing on the SharePoint platform and look for guidance on how to start.</p>
<p>Following recipes present common tasks in SharePoint development as step-by-step guides. The good thing about how the book is structured is that every chapter starts from the beginning so you’re not required to read the whole book. Instead you can skip directly to the part that you are interested in. Although not every recipe clearly describes its goal at the beginning, they are still easy to follow because they are brief and focus on one topic only. Creating List Forms with InfoPath and using the Data Form Web Part to display external data are just two examples of recipes that Ed presents in his book.</p>
<p>Development on the SharePoint platform is very different depending on which workload you are working with and whether your projects require structured and repeatable deployment or if you can customize things using SharePoint Designer. Ed doesn’t go very deeply into Application Lifecycle Management of SharePoint Solutions but he does present recipes that require Visual Studio as well as recipe that can be done using SharePoint Designer.</p>
<p>Ed closes his book with, in my opinion, somewhat misplaced chapter presenting non-developer overview of Web Content Management capabilities of the SharePoint 2010 platform. Although the chapter sticks with the recipe format, considering the audience, the recipes should be developer-oriented instead only presenting WCM configuration capabilities of the SharePoint 2010 platform.</p>
<h2>Summary</h2>
<p>The book is written with experienced ASP.NET developers in mind. Because it’s a cookbook, the book consists of short recipes rather than explaining every aspect of development on the SharePoint platform in depth. Depending whether you learn through theory or if you prefer hands-on experience, you might prefer some additional reading before picking Ed’s book to get more understanding of how the different pieces of the SharePoint platform fit into each other. Ed’s book is a valuable resource if you have not that much experience with SharePoint and are looking for a proven approach to accomplish specific tasks.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=XYtyqOreDaY:luoZt3NL0mk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=XYtyqOreDaY:luoZt3NL0mk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=XYtyqOreDaY:luoZt3NL0mk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=XYtyqOreDaY:luoZt3NL0mk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=XYtyqOreDaY:luoZt3NL0mk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=XYtyqOreDaY:luoZt3NL0mk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=XYtyqOreDaY:luoZt3NL0mk:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/XYtyqOreDaY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/microsoft-sharepoint-2010-development-cookbook-book-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/microsoft-sharepoint-2010-development-cookbook-book-review/</feedburner:origLink></item>
		<item>
		<title>SharePoint Server MVP 2012</title>
		<link>http://feedproxy.google.com/~r/WaldekMastykarz/~3/0EWBh8maywc/</link>
		<comments>http://blog.mastykarz.nl/sharepoint-server-mvp-2012/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 16:18:03 +0000</pubDate>
		<dc:creator>Waldek Mastykarz</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[MVP]]></category>

		<guid isPermaLink="false">http://blog.mastykarz.nl/sharepoint-server-mvp-2012/</guid>
		<description><![CDATA[I have just received an e-mail from Microsoft saying that I have been reawarded the Microsoft Most Valuable Professional (MVP) for SharePoint Server title for another year. Herewith I would like to thank everyone in the SharePoint community for inspiration and their continuous feedback on my work. Thank you!]]></description>
			<content:encoded><![CDATA[<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="" border="0" alt="Microsoft Most Valuable Professional Logo" align="left" src="http://mastykarz.nl/blog/images/SharePoint-Server-MVP-2012_F179/MVP_FullColor_ForScreen.png" width="89" height="139" />I have just received an e-mail from Microsoft saying that I have been reawarded the Microsoft Most Valuable Professional (MVP) for SharePoint Server title for another year.</p>
<p>Herewith I would like to thank everyone in the SharePoint community for inspiration and their continuous feedback on my work. Thank you!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0EWBh8maywc:HyHYHTgMmdM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0EWBh8maywc:HyHYHTgMmdM:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0EWBh8maywc:HyHYHTgMmdM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=0EWBh8maywc:HyHYHTgMmdM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0EWBh8maywc:HyHYHTgMmdM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WaldekMastykarz?a=0EWBh8maywc:HyHYHTgMmdM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WaldekMastykarz?i=0EWBh8maywc:HyHYHTgMmdM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WaldekMastykarz/~4/0EWBh8maywc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.mastykarz.nl/sharepoint-server-mvp-2012/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://blog.mastykarz.nl/sharepoint-server-mvp-2012/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 3.184 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-08 14:33:54 -->

