This example illustrates how to render ASSOCIATIONS - Named and Unnamed (Collections, Query and Asset associated)
GENERAL STEPS TO FOLLOW:
<asset:load name="HomePage" type="Page" field="name" value="Home" site='<%=ics.GetVar("site")%>'/>
GENERAL STEPS TO FOLLOW:
- Load the asset (using asset:load tag)
- Get the association (using asset:children tag)
- Fetch attributes (by looping through list using ics:listloop tag)
<asset:load name="HomePage" type="Page" field="name" value="Home" site='<%=ics.GetVar("site")%>'/>
<asset:children name="HomePage" list="LatestNewQuery" objectype="Query" code="LatestNews"/>
<ics:listloop listname="LatestNewQuery">
<ics:listget listname="LatestNewQuery" fieldname="description"/>
</ics:listloop>
INFO:
INFO:
INFO:
- The above code retrieves the query asset that has been associated with a page asset through the "LatestNews" association
.
- code="LatestNews" - This is required to retrieve NAMED association.
- If asset is associated to another asset, use the above way. (for eg: list of images associated with article assets.)
<asset:load name="NewsCollection" type="Collection" objectid='<%=ics.GetVar("id")%>'/>
<asset:get name="NewsCollection" field="name"/><br/>
<asset:children name="NewsCollection" code="-" order="nrank" objecttype="Article" list="articleList"/>
<ics:listloop listname="articleList">
<ics:listget listname="articleList" fieldname="description"/><br/>
</ics:listloop>
INFO:
- The above code retrieves a collection of articles and then displays the description field of each article
- Notice: for unnamed associations, we use "-" in code parameter (code="-") while using asset:children tag.
- order="nrank" - This can be used to retrieve list sorted by rank started at number 1. Use "nrank desc" for descending order.
- Above mentioned example assumes that your asset was loaded for further purpose to load siteplan or to scatter other values using asset:scatter. But if you only want to retrieve associated assets, don't use asset:load. You can directly load association by providing assetid and asset type info to <asset:children> tag (Check how in tag reference)
--------------------------------------------------------
SUGGESTIONS/COMMENTS ARE INVITED
--------------------------------------------------------