Site Preview
Many times, I am asked a question, “the client wants to approve an asset in advance, but the article should go live only at a given time. How can this be implemented?” In WebCenter Sites this functionality is provided through “Site Preview”. This functionality behaves differently on management server and on delivery server.
- On Management Server
- Allows Content Editors to ‘preview’ site in Insite interface for a future date
- Content Editors see the site as it will appear on a future date
- Can have a site for summer, winter, fall & spring season or can have a special sale on “New Year Day”.
- Allows Content Editors to ‘preview’ site in Insite interface for a future date
- On Delivery Server
- Article will go live at the given date & time./>
This functionality utilizes startdate & enddate. These are default fields in all asset types. Content Editor can specify the time when the article appears on the site. On delivery system, the article must appear between the startdate and enddate. For this the cache should be expired at proper times. But, on management server, one should be able to preview the content before the start date. This is achieved by using asset:filterassetsbydate in the JSP templates.
To use this functionality, the Content contributors must create an appropriate set of assets, and the developers must update the templates that render the assets to include the tag asset:filterassetsbydate. This tag performs the following:
- Determines if it is management or delivery server
- On management server it:
- Disables caching of the current page being rendered
- Accepts the date parameter - passed from the InSite screen date picker
- On Delivery Server, it ignores the date passed in the date parameter, but uses the system date instead
- Filters the input list of assets based on the given date to produce the output list.
Caching Considerations
On the delivery system, in order for web pages to be displayed appropriately for the current date, cache must be expired at the proper times. Therefore, WebCenter Sites Cache Engine includes start and end dates in the factors it uses to calculate the expiry time for cached pages.
On the management system, when a page is previewed in the InSite interface, the asset:filterassetsbydate tag disables page caching for that page. This ensures that the page being served always displays assets filtered by the date being passed from the InSite date picker.
Creating Sets of Assets
When different versions of the same item need to be displayed on different dates, content creators need to create multiple assets. For example, suppose you are creating a page in a web site. You want to run a special version of the page for a one-day New Year’s Day sale event. You would need three />different assets to accomplish this task. Here is how you would create the one-day sale:
- Create the regular asset, setting its end date to the date before the sale day, December 31st 23:59:00
- Create the sales event asset, setting the start date to the beginning of the sale day, January 1st 00:00:00, and the end date to the end of the sale day, January 1st 23:59:00.
- Duplicate the regular asset, setting the start date to the day after the sale, January 2nd 00:00:00
On Management Server, the filter tag will filter the input set of assets according to the given date. Date can be set from preview screen. Pages whose rendering templates use the filter tag are not cached on Management Server.
Limitations of Site Preview
Site Preview allows content editors to preview how the site will appear at a future date. It also ensures that on delivery content will go live at the proper time. But it has the following limitations:
- The content must be published to delivery in advance
- It requires creating different sets of assets
Coding for Site Preview
To code template for site preview functionality, the developers must:
- Create the input list of assets. List should have assettype & assetid as columns
- Filter assets using asset:filterassetsbydate tag
- Process the output list
Create the input list
<%// create the input list %>
// create the input listobject for filtering
%><listobject:create name='__templist' columns='assettype,assetid' /><%
.
.
for(;assetList.hasNext();)
{
.
.
%><listobject:addrow name='__templist'>
<listobject:argument name='assettype' value='<%=ics:GetVar(“c”)%>' />
<listobject:argument name='assetid' value='<%=ics.GetVar(“cid”)%>' />
</listobject:addrow><%
}
%>
<listobject:tolist name='__templist' listvarname='__templist' />
Filter assets using asset:filterassetsbydate tag
<%// filter by date%>
<%
IList templist = ics.GetList("__templist");
if (templist != null && templist.hasData())
{
%>
<asset:filterassetsbydate inputList='__templist' outputList='__assetlist' date='<%=ics.GetSSVar("__insiteDate")%>'/>
<%
}
%>
Process the outputlist
The _assetlist now has the filtered assets. One can loop through the _assetlist and display the results.