Bernard Hennecker's Blog

Experiences with information & data architecture on SharePoint

SharePoint Dynamic Pages

leave a comment »

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:

image

And here is the way the page could look like:

image

Configuration of the dynamic page

  1. Launch SPD and open your site
  2. Create a new empty page
  3. Insert a data view of the news list in the web part zone you wish to display the news details
  4. In the Common Data View Tasks menu, select Edit Columns:
    image
  5. Choose Body as the only field to be displayed:
    image 
  6. In the Common Data View Tasks menu, select Parameters and create the id parameter as follows:
    image
  7. In the Common Data View Tasks menu, select Filter and configure as follows:
    image
  8. For the PlaceHolderSiteName, click on Create Custom Content:
    image
  9. In code view, below <h1 class="ms-sitetitle">, delete the line starting with: <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" …
  10. Go back to Design view; you should now have something similar to:
    image
  11. 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:
    image
  12. 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:
    image
  13. Select Change Layout and select the one below:
    image
  14. You should now have something similar to:
    image
  15. Click on the news title field and display the Apply Styles Task Pane:
    image
  16. Click on .ms-sitetitle to apply that style to the news title field
  17. 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:

  1. Open the web part page containing the web part listing the news:
    image
  2. Click on the news title field and on the attached menu, select Hyperlink in the Format as field:
    image
  3. Answer Yes in the next window; you should now have the window allowing to edit the hyperlink:
    image
  4. 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}
  5. Make sure that the Text to display field still contains {@Title}; manipulating the Address field also updates the Text to display field!
  6. Save the page and… enjoy!
Advertisement

Written by Bernard Hennecker

November 20, 2009 at 14:15

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.