Translate

Saturday, July 6, 2013

Example 1: Rendering Basic Asset

This example illustrates how to render BASIC ASSET in different situations.

GENERAL STEPS TO FOLLOW:
  1. Load the basic asset (using asset:load tag) 
  2. Scatter the loaded basic asset (using asset:scatter tag) 
  3. Retrieve information after scattering the asset via prefix:attributename (using ics:getvar tag) 
CASE 1: If you know asset type(c) and asset id (cid). This is basically used to retrieve information from the basic asset usually to render on page. Following example shows retrieving name after the basic asset is loaded and scattered.

<asset:load name="anyName" type='<%=ics.GetVar("c")%>%>' objectid='<%=ics.GetVar("cid")%>' flushonvoid="true" />
<asset:scatter name="anyName" prefix="anyPrefixName" /> 

<ics:getvar name="anyPrefixName:name"/>

CASE 2: If you know asset type, a field, value and site. This is generally used to get association using asset:children tag after the asset is loaded.

<asset:load name="anyName" type="assetTypeName" field="name" value="someAssetName" site='<%=ics.GetVar("site")%>'/>
(Use asset:children to get associations... COVERED IN LATER EXAMPLES) <asset:get name="anyName" field="description" /> <ics:getvar name="description"/>


INFO:
  • flushonvoid ensures that pages cache for the page is flushed if asset is not loaded or asset is deleted. 
  • Don't use this tag to render flex assets, its very costly (in terms of retrieving info from db as flex asset stores data in various tables whereas basic asset stores info in one table) 
  • Never hardcore asset id (cid) as this asset id keeps on changing from one environment to other. Also try to avoid hardcoding asset type (try to use render:lookup tag) 
  • After the asset is loaded, use asset:scatter tag if you want all the attributes in one go or if only 1 or 2 attributes are required, then use asset:get tag. 
----------------------------------------------------
SUGGESTIONS/COMMENTS ARE INVITED
----------------------------------------------------

No comments: