SharePoint Dynamic Pages
Introduction
In a previous post I introduced the concept of contexts and the way contextual data & information is rendered through a dynamic page. This post extends the explanation and covers the way data or information contained in a standard list or library can be rendered in a custom way. I’ll take the example of a news list and display the news title in the place of the page title and the news body in the center of the page. Here is the news list:
And here is the way the page could look like:
Configuration of the dynamic page
- Launch SPD and open your site
- Create a new empty page
- Insert a data view of the news list in the web part zone you wish to display the news details
- In the Common Data View Tasks menu, select Edit Columns:
- Choose Body as the only field to be displayed:
- In the Common Data View Tasks menu, select Parameters and create the id parameter as follows:
- In the Common Data View Tasks menu, select Filter and configure as follows:
- For the PlaceHolderSiteName, click on Create Custom Content:
- In code view, below <h1 class="ms-sitetitle">, delete the line starting with: <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" …
- Go back to Design view; you should now have something similar to:
- You are now ready to add a data view of the news list. Proceed as above and select Title as the only field to be displayed:
- Configure the id parameter and create the filter as in steps 6 & 7; optionally, you may provide a Default Value for the id parameter so that you can see the output and further configure it:
- Select Change Layout and select the one below:
- You should now have something similar to:
- Click on the news title field and display the Apply Styles Task Pane:
- Click on .ms-sitetitle to apply that style to the news title field
- Save the page
Configuration of the calling web part
Now, the web part displaying the news list needs to be configured to launch the dynamic page with the appropriate parameter. To do so, proceed as follows:
- Open the web part page containing the web part listing the news:
- Click on the news title field and on the attached menu, select Hyperlink in the Format as field:
- Answer Yes in the next window; you should now have the window allowing to edit the hyperlink:
- In the Address field, replace {@Title} with the full pathname of the dynamic page and append ?id={@ID} at the end to pass the ID of the news you want to display:
http://sharepointserver/test4bernard/news.aspx?id={@ID} - Make sure that the Text to display field still contains {@Title}; manipulating the Address field also updates the Text to display field!
- Save the page and… enjoy!