Home > Contents > Index >
Template Tags TOC   |    Alpha TOC   |    Tag Family TOC   |    Purpose TOC   |    Annotated TOC   |    Index 

 

render:lookup

Looks up a map value for a given Template or CSElement.

Syntax

<render:lookup 
        key="name of lookup key" 
        varname="output variable name" 
        site="site name" 
        tid="id of template or cselement"
       [ttype="CSElement|Template"] 
       [match="x|x:|:x"]
        />

Attributes

key (required)
The name of the key corresponding to the value. The key is the only thing that can be hard-coded in a template; hard-coding asset names, types, or values is discouraged.
varname (required)
The output variable name to contain the value corresponding to the key.
site (required)
The name of the site corresponding to this mapping. (mapped values differ across sites).
tid (required)
The id of the template that owns the mapping (usually the current template). If this tag is present in a CSElement, then this is the CSElement id, and ttype must be set to CSElement.
ttype (optional)
CSElement or Template, depending on whether you are trying to look up the mapping for a Template or a CSElement. The default value is Template
match (optional)
The match attribute corresponds to the portion of the value to return. It is a filtering parameter. Map values have several forms, depending on the type of parameter being looked up. If the key is of the form asset type : asset name and match is set to :x then the asset name will be returned. The table below describes the map forms.
Map value forms
Map entry type Map form
asset name asset type : asset name
asset id asset type : asset id
asset type asset type
template name template name

Description

This tag looks up a map value and returns it, filtered based on the match attribute's pattern.

Templates and CSElements contain execution logic, such as JSP or XML code. If asset names, ids, or even types are hard-coded in the Template or CSElement logic, then if the referenced asset is replicated, the template may no longer refer to the replicated asset correctly (the asset id may change). For this reason, Templates and CSElements support mapped variables. Mapped variables contain a key and a value, and are "attached" to a template instance and a site. In a mapped variable, the actual asset information (name, type, id, etc.) is recorded as a map value, and it is assigned an arbitrary key by the template developer. The key is then used in the template logic to look up the value, so that the value is always retrieved dynamically.

Map data is therefore as important to a template as the code itself.

This tag allows map values to be retrieved for the specified template.

errno

The possible values of errno include:

Value
Description
-10004
A required parameter is missing.

Example

Assume a template name is FSIILayout, and the site containing this template has a site prefix of FSII. If that site is replicated, then the FSIILayout template name will be copied, and the copy will have a template name of NewLayout (assuming the new site's prefix is New). Referring to this template by name would result in a failure when the template is executed. Instead, the template name is looked up:

<%-- Look up the name of the layout template --%>
<render:lookup 
        site='<%=ics.GetVar("site")%>' 
        varname="LayoutVar"
        key="Layout" 
        tid='<%=ics.GetVar("tid")%>'/>

<%-- Look up the name of the wrapper page's site entry.  
     Note we want the asset name only, so we must specify
     the match filter. --%>
<render:lookup 
        site='<%=ics.GetVar("site")%>' 
        varname="WrapperVar"
        key="Wrapper"
        tid='<%=ics.GetVar("tid")%>'
        match=":x"/> 

See Also

render:calltemplate

  Home > Contents > Index >

FatWire JSP Tag Reference
Copyright 2005,2006,2007 by FatWire Software
All rights reserved.