Posts Tagged ‘render:calltemplate’


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…

Advertisements

render:calltemplate

The render:calltemplate is one of the well know tag, which is frequently used by the fatwire coders. We will now see the syntax of this tag, and its usage.

USAGE:

This render:calltemplate tag is used when we would like to invoke a Template, or a CSElement, as either a PAGELET (A small part of the page), or an Element, for rendering an asset.

Though we have another tag  “render:callelement” to invoke CSElements, this render:callelement tag is used to invoke both Templates and CSElements as well.

SYNTAX:

The following is the JSP syntax of the render:calltemplate tag. This is in reference with the “Tag Reference” guide.

<render:calltemplate
        site="site name"
        slotname="name of slot"
        tid="caller Template or CSElement id"
       [ttype="caller Template or CSElement"]
       [c="asset type"]
       [cid="asset id"]
       [tname="target Template or CSElement name"]
       [context="context override"]
       [style="pagelet or element or embedded"]
       [variant="template variant name"]
       [packedargs="packed arguments"]>

   [<render:argument name="variable1" value="value1"/>]

</render:calltemplate>

We will now discuss the some important arguments which are specified above.

1. site:  This is a required field. This specifies the name of the site containing the Template to be invoked.

2. slotname: This is also a required field. This attribute defines an user friendly name for the “slot” that is being filled with the called template.

3. tid: This is also a required field. This specifies the id of the template in which this tag is located. If this tag is located in a CSElement, then the value of this attribute should be the id of the CSElement, and ttype should be set to CSElement.

4. context: This is an optional field. If c, cid, and tname are not specified, then this attribute value will be examined to determine which template to call and which asset to render using the specified template.

5. tname: This is an optional field. This field specifies the name of the Template to be called. Typeless templates must be prefixed with a ‘/’. This is required if c and cid are set. If these three attributes are not set, the called template will be determined by looking at context data.

6. style: This is an optional field. The possible values for this field are pagelet, element, embedded.

7. c: This is an optional field. This field specifies the asset type to be rendered by the called Template. The value of this attribute will be passed to the called code.

8. cid: This is an optional field. This field specifies the id of the asset to be rendered by the called Template. The value of this attribute will be passed to the called code. This is required if c is set.

Example usage of render:callelement:

<render:calltemplate tname='<%=ics.GetVar(“ViewTypeVar”)%>’
site='<%=ics.GetVar(“site”)%>’
tid='<%=ics.GetVar(“tid”)%>’
slotname=”PageView”
c='<%=ics.GetVar(“c”)%>’
cid='<%=ics.GetVar(“cid”)%>’
ttype=”Template”>
</render:calltemplate>

In our next post, we will learn how to deal with the “render:lookup” tag, which is frequently used in combination with “render:calltemplate” tag.