24 Best Practices for Creating Future Site Preview Assets and Templates

You can run a special version of a page for an event for as long as the event lasts. In your templates just use the tag that filters assets by date. On the content side, content contributors need to create time-sensitive assets.

Topics:

About Implementing Future Site Preview

Content contributors can preview in the Oracle WebCenter Sites: Contributor interface how their assets will display on the online site at a future time. You’ll use asset start date and end date attributes to enable the Future Site Preview functionality. These two attributes determine the date range during which assets are available on the website. Content creators can specify start dates and end dates in Edit screens in the Contributor interface.

To properly implement the Future Site Preview feature:

Creating Sets of Assets

Do you want to display on your site different versions of an item on different dates? You need multiple assets to accomplish your goal. For example, to run a special version of a page for a one-day New Year's Day sale event, you need three assets. A regular page asset, a sales event asset, and a duplicate of the regular page asset.

For example:

  • Create the regular page asset, setting its end date to the date before the sale day, December 31st 23:59:59.

  • 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:59.

  • Duplicate the regular page asset, setting the start date to the day after the sale, January 2nd 00:00:00.

After the three assets are created, they can be passed as input to the asset:filterassetsbydate tag, which will return the asset to render based on the given date.

For ease of use in searching for the related group of assets for editing, publishing, and filtering in templates, we recommend that developers designate an attribute (such as name) which content contributors fill in using a naming convention when creating related sets of time-sensitive assets.

Writing Templates for Future Site Preview

The asset:filterassetsbydate tag filters assets according to a given date. Appropriate usage of this tag is critical to Future Site Preview functionality.

To understand the proper use of this tag, see these topics:

For more information about the asset:filterassetsbydate tag, see the Tag Reference for Oracle WebCenter Sites Reference

The asset:filterassetsbydate Tag

The filter tag has the following format:

<asset:filterassetsbydate
inputList="inputListName"
outputList="outputListName"
[date="date value in either yyyy-MM-dd HH:mm:ss OR yyyy-MM-dd format"]>

Notice that the filter tag has two input attributes (inputList and date) and one output attribute (outputList):

  • The inputList attribute specifies the list of assets to be filtered based on the given date.

  • The date attribute is optional. The date attribute is expected to be in either yyyy-MM-dd HH:mm:ss or yyyy-MM-dd format. The date attribute should be coded to accept the date value passed from the date picker in the preview screen (use the __insiteDate variable for this).

  • The tag produces an output list (outputList) which contains assets whose start/end dates enclose the given date.

The tag performs the following steps:

  • Checks for the cs.sitepreview property to determine if the template is stored on a content management system.

  • If Future Site Preview is turned off, the system date passes into the date field.

  • If Future Site Preview is turned on, the tag routine:

    • Disables caching of the current page being rendered (see Caching Considerations for more on caching).

    • Accepts the date parameter (passed from the date picker).

    • Checks for the appropriate format of the date passed into the tag.

    • Filters the input list of assets based on the given date to produce the output list.

The Input List

The asset:filterassetsbydate tag requires the input list to contain two columns named assetid and assettype. This input list can be constructed in a variety of ways.

The simplest way to build the input list, and the way Oracle recommends, is for content contributors to follow a naming convention when filling in the attribute of your choice (usually the name attribute). The list-building code could then be written using the asset:search tag or other similar tags to search that attribute for the agreed upon string and construct the list from the search results.

Another method for locating assets to place into the input list is to use the Recommendation asset type to hold a list of assets of interest.

Whichever method you use to determine the assets that have to be filtered, use the listobject tag to construct the input list for the filter tag, as shown in the sample code below.

This sample code creates a list object inputListName and adds a row containing two columns: assetid and assettype. The listobject:tolist then creates the input list called assetInputList. This list is now ready to be passed as input to the filter tag.

<listobject:create name="inputListName" columns="assetid,assettype" />
<listobject:addrow name="inputListName">
<listobject:argument name="assetid" value='<%=ics.GetVar("assetIdVar")%>' />
<listobject:argument name="assettype" value='<%=ics.GetVar("assetTypeVar")%>' />
</listobject:addrow>
<listobject:tolist name="inputListName" listvarname="assetInputList" />

Note that for the sake of simplicity, the code snippet explains the creation of an input list containing only one row. In practice users typically have multiple rows (usually read off from the results of asset:search tag or some other list) added to the list with each row representing an asset that needs to be filtered by a given date.

After creating the input list of assets to be filtered, use the asset:filterassetsbydate tag as follows:

<asset:filterassetsbydate inputList="assetInputList" outputList="assetOutputList" date='<%=ics.GetVar("dateValueVariable")%>' />

To pass input from the Future Site Preview date picker to the date attribute, replace the generic dateValueVariable with _insiteDate.

The tag produces an output list assetOutputList. Read through the list for assets that clear the filter by date test as follows:

<ics:if condition='<%=ics.GetList("assetOutputList")!=null &&     
ics.GetList("assetOutputList").hasData()'%>
<ics:then>
	<ics:listloop listname=assetOutputList>
	<ics:listget listname=assetOutputList fieldname=assetid output=id />
	<ics:listget listname=assetOutputList fieldname=assettype output=type/>

<!--
Perform your usual asset load, asset get and other rendering functions using WebCenter Sites tags here 
-->
</ics:listloop>
</ics:then>
</ics:if>

Caching Considerations

Web pages show expected content for the current date only when asset entries are removed from the cache at the proper times. Therefore, WebCenter Sites includes start and end dates in the factors it uses to calculate the expiry time for cached pages.

Note:

WebCenter Sites does not support the use of start and end dates with Export to Disk publishing. When assets are exported to disk, start and end date attributes are also exported to disk. However, the Export to Disk publishing method has no mechanism similar to the cache cleaning process (which, in other publishing methods, automatically removes expired assets from disk).

On a content management system, when a page is previewed, 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 future preview date picker, rather than serving pages from the page cache, which may have been generated using different date input.