How dynamic content can be used to create a more flexible web site
|Number of votes:||6|
Dynamic content is one of the new useful features of the upcoming version of EPiServer CMS – R2. The idea behind dynamic content is to allow developers to create a ‘tool box’ of reusable features that editors can use any where they want and thereby making the page templates more flexible and powerful.
How to work with dynamic content
As described in the article Dynamic Content - Greater Freedom and Efficeincy for Editors, the CTP version of EPiServer CMS R2 ships with a dynamic content control called ‘Page Property’. This useful control makes it possible to fetch properties from another page. Information such as contact information, that might be repeated on many different parts of the web site can bestored in one location, and re-used throughout the entire web site.
EPiServer CMS developers can easily create more advanced dynamic content controls that editors can use on different parts of the web site.
Developing additional dynamic content controls
As an example of how dynamic content can be used, we have developed a dynamic content control called ‘RSS Feed’, which can be used to show the content of external RSS sources such as news papers or blogs. This control makes it possible for editors to insert news feeds on any part of the web site, making the web site update automatically as new items are published in the external RSS feeds.
Once deployed and configured, the dynamic content control is very easy to use. In the following example, we want a blog feed from ‘EPiServer World’ to appear in the secondary body of a standard page (EPiServer CMS sample templates).
Step 1 – Choose where to insert dynamic content
First, the editors choose where the news feed should appear and click the ‘Insert dynamic content’ in the editor.
Step 2 – Configure dynamic content
The ‘Dynamic Content’ pop up appears and allows us to select which dynamic content control that should be inserted. We also set the following properties on our RSS reader control:
- The URL to the RSS feed that should be displayed
- The maximum number of items to show
- The number of seconds the RSS feed should be cached
The last property is used for performance reasons. The list will be cached for a specified number of seconds because we don’t want to fetch the RSS feed every time the page is requested.
After the dynamic content block has been inserted, it appears as a yellow box in the editor.
Step 3 – Save and view the page
After the page is saved, the news list appears on the web site. The page will now be regularly updated with content from the external news feed.
This is just one example of how dynamic content can be used. The possibilities of creating dynamic controls are pretty much endless. Here are a few more ideas of how dynamic content could be used:
- Allow editors to insert listings of other pages anywhere they like, not restricted to a specific location on a page template.
- Make it possible to easily generate automatic summaries of certain pages, such as news articles.
- Using third party .NET chart controls to allow editors to insert things like nice looking diagrams on the web site.
Implementation and source code
The source code to the RSS Feed dynamic content control can be downloaded here. Please follow these steps to include the RSS feed control in your solution.
- Install EPiServer CMS R2 CTP.
- Upgrade the solution files to Visual Studio 2008 with taget framework .NET 3.5.
- Include the source code files from the zip file in any location in your project.
- In RSSFeed.cs, adjust the paths in the calls to LoadControl and GuiPlugIn attribute according to the location in step 3.
- Register the dynamic content control in the DynamicContent section of your web.config. Please see the article below for instructions.
<add description="Displays a list of items from an external RSS source" name="RSS Feed" type="DynamicContentExample.RSSFeed, EPiServer.Templates.Public"/>
For more technical information on development and deployment of dynamic content controls, please see the following article: