Posts Tagged ‘asset:load’


Some times, we need to modify the Fatwire Flex Content Definitions, that have been already created.

Say for example, there are thousands of Flex Assets, created using a Flex Content Definition. I would wish to remove / add few attributes to the content definition. I’ve done it.

Now, how the new attributes will reflect in the existing thousands of assets?

Simple answer: Just edit and save the assets. The new attributes will be reflected in the existing assets as well.

This is okay, if there are assets in tens, or around that. But, there will be thousands of assets, in reality. We can’t go and edit all the assets which are there in the system, as it is a lot of time taking process.

So, what to do now?

We can load all the assets through code, and use the tags like asset:load, asset:canedit, asset:save, etc to perform our job.

Here is a sample code, which loads and edits the asset, adding a value for the DESCRIPTION field.

//Checkout the asset. This is optional. But, suggestible to be used.

< asset : checkout type=”<%=ics.GetVar(“c”)%>” objectid='<%=ics.GetVar(“cid”)%>’>

 

//Load the asset.

< asset : load name=”SampleAsset” type='<%=ics.GetVar(“cid”)%>’ objectid='<%=ics.GetVar(“cid”)%>’ editable=”true”  >

//Scatter the asset’s attributes.

<asset:scatter name=”SampleAsset” prefix=”Sample“/>

//Set the new value

< ics:setvar name=”Sample:description” value=”THIS IS NEW DESCRIPTION” />

//Gather all the variables
<asset:gather name=”SampleAsset” prefix=”Sample” />

//Save the asset to the database
<asset:save name=”SampleAsset” />

//Checkin the asset.
<asset:checkin name=”SampleAsset” />

Now, INSPECT the assets from the Admin UI. You will find them updated.


Dependencies:

We have two types of dependencies in Fatwire / Oracle WebCenter Sites:

1.Approval Dependency :  This is the dependency that is logged when an asset is approved for publish. When you approve your asset for publishing, the Approval dependency is logged. This dependency is between the asset that is being approved and its dependent (child) assets. This dependency will verify whether the asset that is being approved can be published to the target machine or not. If there are dependent assets, that need to be approved, then this asset cannot be published.

The Approval dependency is logged when the asset is approved for publish.

2. Compositional Dependency : This can be called as Page Composition Dependencies. As the name itself specifies, it is the dependency between the asset and the  pages / pagelets that are rendering this asset. This dependency determines whether the page needs to be regenerated, in case when assets are modified.

The CS logs compositional dependencies when it renders the pages.  On the other hand, the CacheManager checks the dependency log, whether to regenerate any pages, whose content has been outdated.

How Approval dependencies are logged?

The dependencies are logged based on the type of publishing methodology.

Export To Disk :  If the publishing methodology is Export to Disk, the dependencies are calculated basing on the tags that are present in the code of the template that renders the asset.

Mirror To Server : If the publishing methodology is Mirror to Server, the dependencies are calculate basing on the Family Relationships (for Flex Assets )  / Associations (for Basic Assets) between the assets. Both these type of relationships create approval dependencies.

Types of Approval Dependencies:

The Approval dependency type for CSElements and SiteEntry assets, embedded links and pagelets cant be changed. The approval dependency type for the flex family asset types also can’t be changed. The approval dependency of basic asset types can be modified. We set the type of approval dependency for their associated assets when you configure the associations.

Approval dependency can be of three types:

  1. Exists: If this dependency is selected, then the dependent assets (child asset) must just exist on the target machine, and the version number of the child asset doesn’t matter, as long as the child asset is approved and published to the same machine. This means that the asset that is approved (parent asset) can be published even if the child assets changes (in version, content, etc) between source and target machines.
  2. Exact: If this dependency is selected, then the dependent asset must be of the same and exact version on the target machine. The parent asset can’t be published, if the versions of parent and child assets on the source machine do not match the versions of parent and child assets on the target machine.
  3. None: If this dependency is selected, then the approved asset can be published to the target machine, without bothering about the version / state of the dependent assets.
How Compositional Dependencies are logged?

Compositional dependencies are recorded in different ways. There are several tags that log compositional dependencies.

When Content Server executes an asset:load tag, it automatically logs a compositional dependency for the asset that is loaded, and the page that is going to be rendered

Similarly, assetset:setasset, assetset:setsearchedassets, assetset:setlistedassets tags render compositional dependency. When an asset from the assetset is rendered, the compositional dependency is logged.

When these tags are executed, Content Server logs a dependency between the rendered page and the asset by writing this information in the SystemItemCache table.


Earlier, in one of my posts, we have discussed some of the important tags in Fatwire. We will now see them in detail, along with their usages as well.

render:satellitepage

This tag is used to insert another page as a pagelet. This page is something which has been created by a siteentry. We can pass arguments to the page using render:argument tag. This tag will invoke the page specified by the pagename parameter of this tag.

Example:

<render:satellitepage pagename=”Sample\Header”>

</render:satellitepage>

render:callelement

Say if I want to call someother element from my page, to perform some logic, we can use this render:callelement tag. This tag will invoke the element specified in the elementname parameter.

Here, elementname is a required field, and scoped is an optional field. The possible values for scoped field are local, stacked, global.

Example:

<render:callelement elementname=”Sample\BusinessLogic” scoped=”global”>
<render:argument name=”variable1″ value=”value” />
calltemplate>

render:calltemplate

If I want to call another template from my template, to display some pagelet / perform some logic, then we should use this render:calltemplate tag. This tag will invoke the template specified in the tname /  tid field.

Here, we have three required fields : site, slotname, tid.

The optional fields are as follows: tname, ttype, c, cid, context, style

The style field helps us in determining whether this tag is going to invoke the template as a pagelet or as an element. The possible values of style field are: pagelet, element, embedded. If embedded is the value of style field, then the template is going to be called as a pagelet, without being cached as an independent page in satellite server.

Example:

<render:calltemplate
site='<%=ics.GetVar(“site”)%>’
slotname=”MainBodySlot”
tid='<%=ics.GetVar(“tid”)%>’
ttype=’Template’
c='<%=ics.GetVar(“c”)%>’
cid='<%=ics.GetVar(“cid”)%>’
tname'<%=ics.GetVar(“templateName”)%>’ >
<render:argument name=”variable1″ value=”value” />
</render:calltemplate>

asset:load

This tag queries the database for the asset which is specified in the type field, along with the objectid. Then loads the asset into the memory. This tag is to be used only with Basic assets. Or else, performance issues may arise. To load flex assets, use assetset:setasset tag.

Example:

<asset:load name=”sample” type=”sampleassettype” field=”samplefield” value=”value” site=”sitename” deptype=”exists” />

asset:get

This tag gets a single attribute value from the asset, which has been loaded earlier into the memory using asset:load

Example:

outputVariable” />

asset:scatter

Retrieves and scatters all the field values from the object loaded in the memory using asset:load

Example:   scatter vs get
<asset:scatter name=”MainArticle” prefix=”main” />
<ics:getvar name=”first:name”/>,

<asset:load name=”NewsSectionFront” type=”Page” field=”name” value=”News” site='<%=ics.GetVar(“site”)%>’/>
<asset:get name=”NewsSectionFront” field=”name” />
<asset:get name=”NewsSectionFront” field=”description” />
<ics:getvar name=”name”/>,

 asset:children

After loading the asset with asset:load, the asset:children tag is used to load the children of that particular asset. This tag queries the AssetRelationTree table and builds the children list.

Example:

This code retrieves the page assets that has been associated under LatestNews association with the parent. This code is to be used only after asset:load.

<asset:children name=”HomePage” list=”LatestPages” objectype=”page” code=”LatestNews”/>

This code retrieves the page assets that have been associated under LatestNews association with the asset specified in the assetid field. This code can be used without loading the asset:

<asset:children type=”Page” assetid='<%=ics.GetVar(“cid”)%>’ list=”LatestNewQuery” objectype=”Query” code=”LatestNews”/>

 More tags along with usage on the way…

Stay Tuned…