Publishing Pages in multiple locations with Mavention Virtual Pages

,

Many popular Web Content Management Systems allow you to reuse content across the site. Once published you can then include (fragments of) the page in other places on your website, providing a seamless experience to your visitors. And if you ever need to change something, you can do it in one place and those changes will be automatically pushed to all other locations. Reusing content is probably one of the most desired capabilities in WCM, so it’s pretty surprising that it isn’t available out of the box in SharePoint 2010. While SharePoint 2010 has the concept of Reusable Content it’s meant more for creating small content snippets rather than using it for republishing content on your website. And this is exactly where Mavention Virtual Pages gets useful.

What is Mavention Virtual Pages?

Mavention Virtual Pages is a custom SharePoint 2010 Solution that allows you to publish the content of Publishing Pages in multiple locations on your site.

Upon deployment Mavention Virtual Pages installs a new Site Collection Feature called Mavention Virtual Pages.

Mavention Virtual Pages Site Collection Feature

Upon activation the Mavention Virtual Pages Feature will install a new Content Type called Virtual Page and will provision a sample Page Layout called Mavention Virtual Page. The idea here is that the Content Type ships with the basic publishing capabilities for Publishing Pages and additional field that allows you to select a Publishing Page that you want to display.

Virtual Page Content Type

The Mavention Virtual Page Page Layout is a sample Page Layout that you can use for creating your own Page Layouts to support the reuse of pages in your site.

Contents of the Mavention Virtual Page Page Layout

How Mavention Virtual Pages work

The working of Mavention Virtual Pages is very simple. When you look at the sample Page Layout you might not notice anything odd: it contains all the regular pieces that every Page Layout in SharePoint has. The only difference is that the sample Page Layout is attached to the Mavention.SharePoint.VirtualPages.VirtualPage class which makes creating virtual pages possible. So if you start creating your own Page Layouts for Virtual Pages this is one thing that you shouldn’t forget otherwise it will not work.

Using Mavention Virtual Pages: a step-by-step guide

To better illustrate you the working of Mavention Virtual Pages let’s follow a simple scenario where we will create a Publishing Page in one place on the site and will the publish the same page in a different site. This manual assumes that the Mavention Virtual Pages Solution has already been deployed and that the Mavention Virtual Pages Feature has been activated. In this case we will use the sample Mavention Virtual Page Page Layout shipped with the Mavention Virtual Pages Solution.

First, let’s create a Publishing Page somewhere on the site. For this purpose we will use the Article Left Page Layout available with the standard SharePoint Server 2010 Publishing Site. Also let’s include some sample content that we will reuse later on.

Sample Publishing Page created using the Article Left Page Layout

The next step is to reuse the page that we have just published. Let’s go to another place in the site and create a new Publishing Page.

Before you do this, you might want to ensure that you are allowed to use the Mavention Virtual Page Page Layout in your site. You can do this by navigating to Site Actions > Site Settings > Look and feel > Page layouts and site templates and see if the Mavention Virtual Page is on the list of Allowed Page Layouts.

After creating the page let’s change the Page Layout to Mavention Virtual Page:

Changing Page Layout of the newly created Publishing Page to Mavention Virtual Page

The next step is to link the Virtual Page to the page that we created earlier. You can do this by specifying the link in the Linked Page field:

Linking the Virtual Page to the Publishing Page created earlier

The last thing is to publish the Virtual Page. After that you should see the contents of the page that you have linked the Virtual Page to.

Contents of a Publishing Page republished using the Mavention Virtual Page

Notice that the Page Title in the title bar, in the page and in the breadcrumbs contains the title of the Virtual Page, while the content of the page is being retrieved from the linked page.

Now let’s see how Mavention Virtual Pages deal with changes. Let’s go to the original page and change something in its contents.

Contents of the Publishing Page changed

If you navigate to the Virtual Page you should see the refreshed contents of the Publishing Page.

Virtual Page showing the modified contents of the Publishing Page

Benefits of using Mavention Virtual Pages

Mavention Virtual Pages is a great solution if you need republishing capabilities in your Web Content Management solution based on the SharePoint Server 2010 platform.

Mavention Virtual Pages works using a simple concept and contains just a few lines of custom code of which all is within the supported public API of SharePoint Server 2010. This makes the Solution robust and reliable. Mavention Virtual Pages use standard controls shipped with SharePoint to render the content so there is no data loss while using Virtual Pages.

Although retrieving the data from linked Publishing Pages happens dynamically, there is no performance penalty when combined with caching and all the content of the Publishing Page linked to a Virtual Page is being retrieved from cache just as it was a part of the Virtual Page itself.

Mavention Virtual Pages is a great Solution if you have a lot of similar pages that you want to publish in multiple locations on your website. As it’s based on Page Layouts it allows you to quickly republish existing pages in other locations. Additionally as it works with anonymous users, it makes a great Solution for your Internet-facing website.

Future considerations

This is the first release of Mavention Virtual Pages. While it successfully covers the most common scenario’s there are few things that you should consider before using it in your solution.

Web Parts in content

SharePoint 2010 allows you to include Web Parts in content. And although from the content editor point of view seems like the Web Parts are a part of content that is being retrieved by Virtual Pages, they actually live outside of the content. While rendering the content, SharePoint replaces markers in text with the Web Parts that physically live in a hidden Web Part Zone. This is why at this moment Mavention Virtual Pages don’t support Web Parts in content.

Virtual Pages are Page Layout-based

Mavention Virtual Pages are based on Page Layouts to render the contents of linked pages. While it gives you a consistent experience from the development point of view, it might seem limiting from the content editor point of view. To link to multiple types of pages, like press release or event, you need multiple Page Layouts linked to the Virtual Page Content Type. Because a press release will very likely contain different set of information than an event, you will have to create two separate Page Layouts to display the information.

Usage reporting

Intensively using Virtual Pages might turn into a nightmare from the content management point of view. While it gives you to great ability of reusing content that is already there in your website, it doesn’t provide you with an overview of which page has been linked to and from where. So when you delete a page published in one page, you might break something in another without even knowing it. Providing an overview of pages that are reused somewhere else in the site is definitely a great idea for a future improvement.

Deployment

As you might know by now, the Publishing capabilities of SharePoint Server 2010 are not yet available in the Sandbox. This mean that you need your IT department to get this deployed. Hopefully this is something that we will see changing in the future releases of SharePoint, but at this moment this Solution is available only as a Farm Solution.

Download: Mavention Virtual Pages (WSP, 7KB)

Technorati Tags: ,


Possibly related posts

16 Responses to “Publishing Pages in multiple locations with Mavention Virtual Pages”

  1. John Liu Says:

    Curious, how complex would it be to support push between different site templates? For example from a publishing site to a team site.

  2. Waldek Mastykarz Says:

    @John: the approach I've described above is a pull not a push. There is no physical copy of the page in another location. Additionally Team Sites out of the box don't support Publishing. If you activate Publishing there shouldn't be any difference as when you would be using a Publishing Site.

  3. John Liu Says:

    Sorry shouldn't have used the word "push" – I understood the pull mechanics.

    It's just my little mind wandering about the possibility of a public team site (SPF2010) sucking content out of an internal publishing site (SP2010).

  4. Waldek Mastykarz Says:

    @John: I'm not sure you would be able to use this approach here due to the fact that one site has anonymous access enabled while the other hasn't. I'd say that you should be looking at Content Deployment instead as it gives you more control of what's available to public and what's not.

  5. Joe Says:

    Great add on! You're right, one would expect this to be available out of box, but then we'd have nothing to build.

  6. Michhes Says:

    Nice work "productising" this! We hand-cut a very similar 2007-based solution to virtualise the five English-language variants hanging off westernaustralia.com (used to be variations once upone a time but no more). Now only the /en page exists physically and the /sg, /uk/, /nz, /au are virtual, displaying the /en content by default if no content override is provided. I can attest this approach–while massively scary(!)–scales well to a highly trafficked site like ours. We've even taken it further to ensure content URLs on a page that exists in a given site remain rooted to that site.

  7. Franck Says:

    Nice work (as usual)! Thanks for sharing it.
    It's working fine with different page layouts (and content types)… until I tried one with a managed metadata field. If I add the TaxonomyFieldControl of the managed metadata field on the page layout inheriting from VirtualPage, it's working fine in edit mode (when I create the page). But, once I selected the linked page and saved the page, I got the following error:

    Microsoft.SharePoint.SPException: Failed to get value of the "PressReleaseType" column from the "Managed Metadata" field type control. See details in log. Exception message: Invalid field name. {1e45ef7a-56f3-4635-a55a-b4905418daf8} http://mydev/sites/PubPortal/VirtualSite /sites/PubPortal/VirtualSite/Pages.

    The invalid field name seems to be related to the "hidden" Note field paired to each TaxonomyFieldType field. Is this due to the fact that the ItemContext is changed on the Taxonomy field but not on the "hidden" one?

    Any idea?

  8. Waldek Mastykarz Says:

    @Franck: Virtual Pages by default rewrites the context for all controls that inherit from the FieldMetadata control, so it could be that if the Managed Metadata control that you are using doesn't inherit from that base class it refers to the Virtual Page itself rather than to the page that is being linked to. Which control are you using to display your Managed Metadata field?

  9. Franck Says:

    I'm using the TaxonomyFieldControl which inherits from FieldMetadata. According to MSDN:
    "The taxonomy field control contains a taxonomy Web tagging control. It is reponsible for initializing a new instance of the Web tagging control with all of the properties for the TaxonomyField object. It also initializes the taxonomy Web tagging control with its initial value, and then updates the TaxonomyField object with the selected value after edit."
    But this TaxonomyWebTaggingControl doesn not inherit from FieldMetadata. Could this be the reason of the issue?

    it appears that this TaxonomyFieldControl contains a

  10. Waldek Mastykarz Says:

    @Franck: this could be the reason indeed. I will try to investigate this as soon as possible and will get back to you as soon as I have some results. Thank you for your feedback :)

  11. Franck Says:

    I extended your page layout with some fields of the "article page" content type (e.g. ).
    If I create a virtual page linking to an article page within the exact same site, everything goes fine.
    But if I create a virtual page linking an article page in another site, the "ArticleByLine" textfield generates the following error (although the "PublishingPageContent" is still well displayed):
    Failed to render "Byline" column because of an error in the "Single line of text" field type control. See details in log. Exception message: Value cannot be null. Parameter name: input.
    I got the same error with the "ArticleStartDate" field (DateTimeField).
    Any idea?

  12. Waldek Mastykarz Says:

    @Franck: Are you sure you haven't done anything more? I've just tried what you said with a new Publishing Site. I've created a Publishing Page in the Root Web using the ArticleLeft.aspx Page Layout. Then, under Press Releases I've created a Virtual Page. I customized the standard Virtual Page Page Layout to include the ArticleByLine and ArticleStartDate Fields and it works all fine here. Just to be clear, when you say Site, you mean actually a Web or a Site Collection?

  13. Franck Says:

    I played the same scenario you did on a fresh site collection (publishing portal) and I got the same error with the ArticleByLine and ArticleStartDate Fields.
    I didn't install yet any CU (still in 14.0.4763.1000). What SP version are you running?

  14. Waldek Mastykarz Says:

    @Franck: That't weird indeed. I'm using the same version as you, haven't installed any CU's as well. What are the locations of your Publishing Page and Virtual Page?

  15. Franck Says:

    Regarding the PL, I just copied/pasted your PL into a new one and added the following lines above the "PublishingPageContent" field:

    Then I created a publishing page in the root web using the ArticleLeft.aspx PL and a virtual page using the new PL under the PressReleases web site. The virtual page failed displaying the start date and byline.
    If I create a virtual page using the new PL in the root web (i.e. the same web as the linked published page), there's no problem at all! Totally weird!

  16. Franck Says:

    Regarding the PL, I just copied/pasted your PL into a new one and added the following lines above the "PublishingPageContent" field:

    Then I created a publishing page in the root web using the ArticleLeft.aspx PL and a virtual page using the new PL under the PressReleases web site. The virtual page failed displaying the start date and byline.
    If I create a virtual page using the new PL in the root web (i.e. the same web as the linked published page), there's no problem at all! Totally weird!

Leave a Reply

Security Code:

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS
Copyright © 2007 - 2012 Waldek Mastykarz

Creative Commons License