Tuesday, July 1, 2014

SharePoint 2013 – Add DataView WebPart with SharePoint Designer 2013

Summary : SharePoint 2013 – Add DataView WebPart with SharePoint Designer 2013, Create a new DataView WebPart with SharePoint 2013, How to add a new DataView WebPart with SharePoint Designer 2013
As in previous versions of SharePoint In SharePoint 2013, you can still add Dataview webparts to your pages using SharePoint designer 2013 but with a an exception that you no longer see a Design View in SharePoint Designer 2013.
Adding DataView with Source is still not very clear. I saw a bug when I tried to add a Dataview but it would only show empty data view and not the List\Library list. However, I found a workaround that and was finally able to add a XSLTListView WebPart on a page.
In this post we will see the Step-by-Step Tutorial on how to add a DataView in a SharePoint 2013 site page which will be viewed in Browser.
1. Open your site in SharePoint designer 2013.
2. Next, Create a WebPart Page.

Give your Webpart Page a name and click ok.
3. Next Edit file to Open.

4. Click on “CODE VIEW TOOLS” tab and then click on Parse HTML

5. Next click in of WebPartZone and then click on Insert Tab and then DataView.

If you don’t see this and just sees the “Empty Data View” Option select that and then again click in the WebPartZone and then Data View again. Then you will see the datassource Options. The earlier (empty data view) will add a DataFormWebPart that you can delete that if you want.

This might be a Bug in SharePoint 2013 beta Designer.

Once you add a DataView for a List\Library you will see a new XsltListViewWebPart added.

6. Click on XsltListViewWebPart and you will see the DataView’s tab appear.

Here you can Add\Columns,Set Paging,View Data Source details and rules and can do pretty much everything you use to do with your OLD dataview.
If you want to edit the XSLT of this webpart you can navigate to “DESIGN” tab and click on “Customize Entire View”.

7. Preview Changes – Even though the Design View is missing you can still preview the changes with “Preview in Browser”.

8. Once done Save the Page and Check in.

SharePoint 2013 allows users to Display/Hide Quicklaunch 1 click

With Quicklaunch in Team Site, I saw a button in the top left called “Focus on Content”

after you click on it

SharePoint 2013 Design Manager – Device Channels

SharePoint 2013 has introduced a new way for power users and advanced users to Brand their SharePoint Site. The Design Manager is a new option in the Look and Feel section of the Site Settings.

The Design Manager has 8 steps that will help you get your site branded to your needs. These are not necessarily sequential steps, meaning you do not have to do them in order.
Step 1 – Welcome

I won’t really cover step 1 as it is just the welcome step. However it does allow you import a Design Package (created in step 8) which is a .wsp SharePoint solution file that contains your master pages, images, css, etc.. And will deploy it for you. You can also use the “Pick a Theme” or pre-installed look as they call it. SharePoint 2013 introduced a gallery of themes or templates for you to choose from. You can change the background, logo, fonts, and colors amongst other things, pretty neat.

Step 2 – Device Channels
What I really want to talk to you about today is the Device Channels that are part of the Design Manager now. The ability to have multiple designs based on browsers or devices – COOL!

Creating a Channel is straight forward enough:
First give the channel a name
Then give it an Alias, this is the important part as it is the name that will be used in the master page to use different settings. If you change the alias after it was applied you will have to manually go in the master page to change the alias name.
You can write a description as well
The most important section of this form is the Device Inclusion Rules. In here you can enter
one or more user agent substrings. I couldn’t find a good exhaustive list, hopefully a reader will comment with a better list. Here is what I found so far http://www.useragentstring.com/pages/useragentstring.php
But it’s way too detailed. As an example, Microsoft writes “Windows Phone OS” as a Device Inclusion Rule.
Sample user agent substring values
DeviceUser agent substring(s)
Windows Phone
  • Windows Phone OS 7.5 (Specific to Windows Phone 7.5 phone.)
  • Windows Phone OS (Generic substring for all Windows Phone versions.)
iPhoneiPhone
iPadiPad
AndroidAndroid

Powerful
Now, by creating these “Device Channels” you can effectively change the way your SharePoint 2013 site looks like. In Step 6 “Edit Page Layouts” and Step 7 “Publish and Apply Design” of the Design Manager, you can associate different codes, layouts, master pages based on the Device Channel we created above.

Really appreciating the Design Manager. I’ll keep exploring it and keep you updated.

Step by Step: Create a SharePoint 2013 Composed Look

With the introduction of SharePoint 2013, we saw many things change. Some of the major new features relates to branding. In previous posts, I have already explored in detail how to convert a regular HTML into a SharePoint Master Page using the new Design Manager. I also covered some of the cool things we can do with the Design Manager like setting up Device Channels, etc. In this article, I want to focus on the new “Composed Look” available in SharePoint 2013. Now I am not going to show you how to pick one that is already available, I am sure you can figure that one out. No, in this article we will create our own and make it available for deployment, step by step.

Discovery on how to use Composed Looks in your company

Perhaps it’s just me, but I just realized how powerful these Composed Looks are in the enterprise. The idea of templating your Branding, yet providing the flexibility to the user to make minor changes. I started thinking and saw the possibilities.

What is a Composed Look?

First, we need to make sure we understand what it is before we can start. So what is a Composed Look? A possible definition of the word “Composed” could be: “To make or create by putting together parts or elements”. I believe this fits with our use of this feature. A Composed Look is made up of:
  • Master Pages
  • CSS
  • Color palettes
  • Font palettes
  • Background image
Changing the Composed Look using the interface:

And some of the changes a power user can make using the interface:

What does this mean for you?

This means we can package a master page with its CSS, color palettes, font palettes and background image and have it deployed in the enterprise. With Composed Looks, you can now offer your Power Users a list of branded looks and allow them to choose an appropriate look as well as giving them limited control to make changes to the colors, image or font. You could be providing them Composed Looks.

Let’s create a Composed Look

Start with the SharePoint Master Page

I won’t explain how to create a Master Page in this article as I already covered here. But the first step in creating a Composed Look is by creating a Master Page. The Master Page is the HTML structure that holds the design together with SharePoint controls to make sure everything works.
In this example, I will simply copy one of the existing Master Pages and name it differently for our example. However, I need to know what to copy.
In SharePoint 2013, Master Pages are made of an HTML file, which is where we make our main customizations, a Master file that SharePoint reads and a Preview file.
Do Not modify the .master file this file is handled my SharePoint.
The .Preview file should have the same name as the HTML and Master file, it is used to make Master Page you create available in the drop down menu of “Site Layout” when modifying a composed look.
**You don’t need the .preview file to create a Composed Look but you will need it if you want to complete your Composed Look and make your Master Page available in “Site Layout” **

I copied and renamed the Oslo master page using SharePoint Designer. You can use SharePoint Designer 2010 or 2013 with SharePoint 2013; they both work for what we need to do.

You don’t need to rename the oslo.master file, it is linked to the html file and should rename itself.

Of course in this example my Master Page is still using the default SharePoint CSS files. In your case, it will be using a custom CSS file don’t forget to link it as you would usually do in your html file. It doesn’t impact the rest.
Let’s make sure my file are working for now by going to Site Settings and clicking on “Change the Look”. Select any look to modify and you should now see your master page appearing in the “Site Layout” drop down menu.

Of course right now it looks and acts exactly the same way as Oslo. I’ll explain the Preview file later on in this article.

The CSS and how to make it work with Composed Looks

Copying the Master Page was the easy part, now we have to make sure that the CSS the designer or you wrote is compatible with Composed Looks. What do I mean by compatible? The whole point of a composed look is to give the ability to Power Users to make customizations like colors and font.
If you have experience with SharePoint 2010 themes, you’re going to find this very familiar.
Earlier we mentioned that a Composed Look is made up of a few things, which include Color Palettes and Font Palettes. How do I know this and where do you find them?
Navigate to Site Settings and locate the Web Designer Galleries section to click on Composed Looks.

In here you will see the configuration for each available Composed Looks in the site. One of our final goals will be to have our own listed here. For now, we just want to see how they are configured.

As you can see, a Composed Look needs to know what its Master Page is, Theme (which I call a Color Palette), background image and font scheme (which I call a Font Palette) is.
So my next step will be to see what this .spcolor file is made of.

Understanding the .spcolor file

Using SharePoint Designer, navigate to /_catalogs/theme/15/ and there you will find all the .spcolor files we are looking for. Of course they are also located directly on the file server where SharePoint is installed but I don’t recommend modifying those files.
Here is what you can in SharePoint Designer once you navigated there:

Copy paste one of the Palette spcolor files and rename it. The files will be displayed alphabetically in SharePoint.
I copied the Palette010 and renamed it in this example.

Because my file name starts with a B and all others with a P, my color file will be displayed first in the Color menu of my Composed Look.

If you scroll down you will see that there is another Color Palette with the exact same configuration as the first one. That’s because I copied the Color Palette 010 and made it my own to customize.
Editing the spcolor file can be done using SharePoint Designer 2010, 2013 or even notepad if you want.

The file is very straight forward and you can create as many Color files as you want. This file simply associates a “name” with a color value.
The cool thing is that SharePoint 2013 supports RGBA, this means you can apply transparency as well!
I won’t explain how to write the color value as someone already wrote a very detailed article on just that.
Let’s change the color value of SiteTitle and WebPartHeading for the fun of it and see what happens.


I decided to go with a light sort of green so we can see the difference. Save the file and navigate back to your site settings to choose your custom color palette.

If I look back at the original color palette that I copied from, we should see a small difference.
Original:


As you can see, just by changing the Color palette from the “Change the Look” screen of the Composed Looks I was able to give a different design to my SharePoint site.

Summary of the spcolor file:
An SPCOLOR file is a file that associates reusable names to a color value. Look at them like variables.

Using the names provided in the spcolor file in your CSS

Very similar to SharePoint 2010 themes, you can now apply these names provided by the linked spcolor file directly in your CSS.
Wait, how?
Why were my changes applied instantly after I saved my spcolor file? I never referenced those “names” in the spcolor file to anything.
If you recall, I simply copied one of the out of the box master pages offered by SharePoint. That includes the link to the out of the box CSS file used and referenced by the Master Page. That CSS file already has the names in the spcolor file used within it.
Here is an example of what the SharePoint CSS looks like:
1
2
3
4
/* [ReplaceFont(themeFont:"title")] */ font-family:"Segoe UI Light","Segoe UI","Segoe",Tahoma,Helvetica,Arial,sans-serif;
/* [ReplaceColor(themeColor:"SiteTitle")] */ color:#262626;
}
<
Notice that the color already has a value of #262626. However, it is preceded by what looks like a CSS comment with one of those “names” used in the .spcolor file.
You guessed it, when writing your CSS you can actually reference any of those names used in our spcolor
file anywhere. Once the Color Palette is applied through the Change the Look menu in site settings, it will overwrite whatever color you had specified in your CSS to the one in the spcolor file under the associated name.
Your responsibility:
It will require extra work when building the CSS to make sure you think about the possible changes you might want to apply.
Powerful in the enterprise:
Imaging the possibilities, the Composed Look can offer your company. Having a design created that can be tweaked by department or division or even by region. Applying slightly different colors but only at the places defined in the CSS.

The spfont file works the same way

As you may have noticed in my piece of CSS above, we can do the same thing to font as we did with colors. By that I mean, specifying our desired font in the CSS and allowing users to switch “Font” from the Choose the Look menu. Just like our colors, the Font palette will go through our CSS to find which classes have a “ReplaceFont” attribute and replace it with what we specify.
Let’s open the spfont file and see how it works. The spfont file was located in the same folder as our spcolor file /_catalogs/theme/15/.

The spfont file has already been explained here in detail so I won’t copy everything here.
The file is very straightforward if you understood the spcolor file, essentially it is the same concept.

In short, the file is made of fontSlots, which is very similar to the “name” in spcolor. For each of these fontSlot you can specify the font you would like to use based on the language of the user. You can erase all of the <s:font> lines that you do not plan on using but you cannot remove <s:ea> and <s:cs> as they are required by Composed Looks to work.
Then, you simply use the fontSlot in your CSS as we saw earlier.
/* [ReplaceFont(themeFont:"title")] */ font-family:”Segoe UI Light”,”Segoe UI”,”Segoe”,Tahoma,Helvetica,Arial,sans-serif;
In this scenario, my CSS specified the Segoe font family but it will be replaced what whatever is associated to “title” in my spfont file referenced by the active Composed Look.

The Preview file for the Master Page

If you recall, I copied a master page at the beginning of this article. Even if I had created my own master page, I would still need to copy a Preview file and rename it exactly like my master page to associate them together.
The preview file is used to make the Master Page available in the “Site layout” drop down when creating a Composed Look.
The preview file is split into the definition of CSS classes including the Color Palette and Font Palette that we want to use as well as some html to preview your design in the Composed Look window.

Creating the new Composed Look

All that is left for us to do is to put the files together into a Composed Look. We’re going to go back to the Site Settings under the Web Designer Galleries to modify or create a new Composed Look.

Click on New Item:

Enter all the necessary information to create a Composed Look.
The Image URL is for the background image that will be applied to the <body> html tag directly.
The next time you navigate to the “Change the Look” setting under you Site Actions or Site Settings you will have a new Composed Look available that will include your Master Page, CSS, Colors, Fonts and background image if it applies.

Deploy your Composed Look as a solution

SharePoint 2013′s Design Manager also offers a feature to Create a Design Package. This can be found under the Design Manager options in Site Settings.

There is a good MSDN article that covers this topic here:
msdn.microsoft.com/en-us/library/jj862342.aspx
This will create a WSP file for you to download and deploy in other Site Collections. The package includes all the custom files that we have created as long as you followed the instructions or warnings on the MSDN link above.

Download your file to your desktop or on a shared drive available to the team rather.

You can always check the content of the file by renaming it to a .cab file and exploring.

Navigate inside the Modules folder under files you will see that all your files have been packaged and ready to use as a WSP.

I hope that this opens your eyes to the possibilities that the Composed Looks can offer to your business, I know it definitely helped me understand the value a lot better when I started playing with my own Master Pages.
**UPDATE** Don’t forget to expect the Theme Slots tool to come out shortly for SharePoint
Theme Slots tool for SharePoint

Managed Meta Data Navigation In SharePoint 2013

Let's assume we need to create an Intranet portal for an enterprise based on SharePoint 2013 and this portal should be based on several different site collections. Each site collection has its own subsites and they built the navigation items for this site collection. And that's the challenge: although each site collection as its own navigation (and does not include the navigation of other site collections) the portal should have an integrated navigation - based on the navigation of all included site cite collections.

What we need to achieve is this: the portal should have an integrated navigation - although it uses several site collections. The best way to do that is to use Managed Metadata Navigation.

Let's make an example: the portal is based on a web application with two site collections. Each site collection contains three sites. Site collection 1 has these sites (site1, site2, site3) and site collection 2 has these sites (site4, site5, site6).

This is how my demo portal looks like:

I1

The questions now is: how can we setup an integrated navigation - or in other words: how can we achieve, that the sites 4, 5 and 6 are also used as navigation elements in Site Collection 1 - although they exist in Site Collection 2 only? And how can we achieve that the sites 1, 2 and 3 are also used as navigation elements in Site Collection 2?

That's where Managed Metadata Navigation comes into play.

First I need to create the Managed Metadata Navigation for Site Collection 1:

I2

After that I change the navigation settings for Site Collection 1 this way:

I3

With these settings my site collection now looks like this:

I4



Now I need to added the sites from Site Collection 2 to the navigation for Site Collection 1:

I5

Because Site4, Site5 and Site6 are members of another site collection (Site Collection 2) I need to provide links like this:

I7

Now the Metadata Navigation for Site Collection 1 is configured and the site collection looks like this:

I7

Site Collection 1 now uses navigation items that are based on different site collections.


But how about Site Collection 2? I could create another Term Set (e.g. NavSiteCol2) and create all items again manually - but there is another way!

Instead of completely doubling a term set with all terms I only create another term set (NavSiteCol2) without any terms … and I want to 'reuse' the navigation items from NavSiteCol1 here. To do this I open the context menu of newly created NavSiteCol2 and choose 'Pin Term With Children' …

I8

In the next dialog I need to select the terms from NavSiteCol1 that should be reused in NavSiteCol2:

I9

Unfortunately I need to do this six times :-( After some clicking and clicking and clicking … the Metadata Navigation now looks like this:

I10



Now I'm ready to setup the navigation for Site Collection 2:

I11

And now it's time to test the newly created portal navigation. First I open Site Collection 1 and click each navigation item one by one - everything works as expected. Now I open Site Collection 2 and click on the first navigation item 'Site1' … and this is what happens:

I12

Why that? When checking Site Collection 1 all navigation items worked without errors? And the navigation items of Site Collection 2 have been 'cloned' in Central Administration … so why is there a problem in Site Collection 2, but not in Site Collection 1?

To answer that, we need to go back to Central Administration and have a look on the items Site1, Site2 and Site 3. if you compare their settings wit h the settings of for example Site4 you might notice the difference. Site1, Site2 and Site3 don't have an assigned a URL - and that's the problem. For Site Collection 2 these items (Site1, Site2 and Site3) are 'foreign' items - or in other words: they are part of another site collection. And they need to have an URL like Site4, Site5 and Site6 to be accessible from outside of Site Collection 1!

After assigning an URL to all navigation terms in Central Administration the integral portal navigation works as expected! By the way: sometimes you need to open the site collections navigation settings after changing settings in central administration to ensure that the changes have been taken over! But that might only be an issue of my development environment (or maybe I run out of patience to soon).

There might be one question left: why do I need to create an identical clone of NavSiteCol1 to be used as Managed Metadata Navigation items for Site Collection 2? Why can't I use NavSiteCol1 as Managed Metadata Navigation items for Site Collection 2 too?

OK - let's try this:

When I try to use NavSiteCol1 for Site Collection 2 too - this is what happens:

I13


You don't have to create one complete Metadata Navigation and 'clone' it completely - as I have done in the first example. In real world scenarios you create a Managed Metadata Navigation Term Set for each Site Collection with only the local navigation items - like this:

I14

After that Site1, Site2 and Site3 get pinned to NavSiteCol2 - and Site4, Site5 and Site6 get pinned to NavSiteCol1 - like this:

I15

I have been asked if that kind of Managed Metadata Navigation can be used for one Web Application only? (Unfortunately I deleted this comment by mistake). Let's check this :-)

I added another item to my metadata items targeting a site in another Web Application:

I16

The sites Site1 to Site6 are all belonging to Web Application 1 (http://devsp2013:8888/). The new item SiteWA2 belongs to another Web Application (http://devsp2013:7777/). As you can see in the above screenshot I already pinned the newly created item (SiteWA2) to the existing metadata navigation items.

And this is how this looks like in the browser:

I17

When I click on SiteWA2 the root site of the newly created Web Application is opened.

There is just one thing you need to be aware of: When you want to create a metadata navigation for more than one Web Application, don't use local or relative links (like I have done in the sixth screenshot) - you need to use absolute URLs:

I18