So you should all know by now that SharePoint 2013 Search is amazing. Not just the crawling piece but the presentation layer too. Using the “Content by Search” and the “Search Results” web parts means that you can really load any content anywhere without much effort. The only real thing to understand is how to build the query and how to style it, which in this version of SharePoint is easier than ever. I was recently working on a My Site Implementation and needed to show a separate web part that showed some information about the current user. So the idea was to replace the “Profile Info” web part with individual web parts that could be styled uniquely. To begin with a custom field was added to the user profile called “Biography“, this was slightly different to the “About Me” field as the “Biography” data was really going to be imported into that field from somewhere else.
I then updated this field with content within the User Profile Service Application.
No when we view the out of the box “Profile Info” web part is displays the following:
As you can see not the most appealing design and does not really meet what we needed. Remember the idea being that individual web parts are added to the profile page to display each block of profile information in a desired format.
Now comes Search to the rescue. Firstly every piece of metadata etc. that we need to use in a “Content by Search” web part for example has to be a manage property. If we look at what search has crawled we see the following property:
Now if we look at the managed properties we don’t see anything. So firstly we need to create the property and map it to our user profile property.
Now to kick off a crawl for in the SharePoint Farm. Wait a little time for that to complete and then we are ready.
So add a “Content by Search” web part to the page. We will then “Edit the Query” and change it to the following:
We will then add “Keyword Filter” that uses the query string of for the account to filter the results. If we don’t do that then we get all the results for all users.
Now when we set this as the query, we will only get your profile showing in the results preview.
We can now save the web part and then we will set the styles. For this I am not going to style it in this post, we will simply set it to use the diagnostic output.
Now that we have it set to diagnostic it will render an image for the picture and then present Line 1 to Line 10, which of course come from the style chosen. We will make a change to Line 1 replacing the text “Title” with “Biography“.
Now save the web part and the page and see what it looks like.
Obviously it is not very pretty at the moment but with a custom html template it can look exactly as you want it too. The key here is that anything that is surfaced in SharePoint and can be indexed by SharePoint can be rendered this way. No longer do we need to stick with the standard presentation of the out of the box controls but we can create dynamic search driven sites, pages and even profile pages.
If we did create a style (basic one) it could look like this or something significantly cooler J
I hope this helps you realize how powerful the search mechanism can be for anything in SharePoint.
You must log in to post a comment.