SharePoint Contexts Implementation
In the previous article, I introduced the concept of contexts. Let’s have a look now at some of the implementation details.
Preliminary
The setup of the site columns, lists and libraries is very generic and does not require a detailed explanation.
A few items should be added to the lists to allow testing and viewing while building.
Context List
A context list similar to the one shown in previous article needs to be commissioned. To the minimum, it should contain the site columns that allow the characterization of a context. In our example, they are Industry, Solution and Keywords. In addition, a few other fields that may be useful on some of the pages can be added. In our example, they are Contact and Page Title. Contact allows a precise filtering of the contacts list to display only one leader on the context page while Page Title is simply used to assign the title of the page.
Dynamic Page
The template or dynamic page that will render the items relevant for the context selected needs to be built with SharePoint Designer (SPD). To do so, follow the next steps:
- Launch SPD and open your site
- Create a new empty page
- Insert a data view for each of the lists and libraries you want to display on the page
- In addition, insert a data view of the Contexts list and make sure it is hidden; your page should look like:
- For the Contexts data view, define the context parameter as follows:
note: the Default Value is not required but may sometimes help when building the page - Filter the Contexts data view as follows:
- For each of the data views on the page, define parameters as follows:
- Then filter as following:
- Finally, for each of the data views, establish a web part connection with the Contexts data view. Follow the normal procedure and make sure you select Get Parameters From in the following window:
and on the next window, map the relevant fields together as follows:
- Accept all other defaults values
- [Update: if you find that the next steps do not provide enough information, you may want to read another post where I detailed this extensively]
To use the Page Title from the Contexts list and display at the top of the page, allow custom content in the PlaceHolderSiteName content place holder, replace the default data with a data view of the Contexts list and configure Page Title as the only field to be displayed - To filter and display the appropriate Page Title, you can either add another web part connection as explained above or retrieve the context directly from the url; in such case, add the context parameter as follows:
- and filter the Contexts data view as follows:
- Select the Page Title field and, in the Apply Styles task pane, select .ms-sitetitle as style:
- Save your page and test it with some of the contexts defined by using an url similar to:
http://sharepointserver/test4bernard/home.aspx?context=aerospace
What’s next
In the next article I’ll explain why I’m using a Contexts list instead of providing all parameters in the calling url.