Adding Items to XLinks Dynamically
Release 1.0 - ...
The XLinks macro supports the datatable resulttype, so if we want to add data to it dynamically, we'll have to save it as a datatable, add data to it using the datatable methods, and then display it:
| Smartsite SXML |
|
|---|---|
<se:xlinks parent="2" resulttype="datatable" save="page:x" /> <!-- load links -->
<se:hidden>
<se:pagetranslations id="links" whitespace="remove"> <!-- helper translations -->
<se:collection>
<se:member name="add(nr, title)"> <!-- define smart 'add' function -->
{buffer.set(nr, translation.arg(1))}
{datatable.add(page.buffer.get(x), $nr,
cms.getitemcode($nr, default=sys.throwexception('InvalidArgument',
'Item number not found while adding to links')), translation.arg(2, default=itemdata.rawfield(title, $nr)))}
</se:member>
</se:collection>
</se:pagetranslations>
<!-- add links to existing list -->
{translation.links.add(2)}
{translation.links.add(225)}
{translation.links.add(22335)}
</se:hidden>
<se:format inputdata="{datatable.sort(page.buffer.get(x), 'Title')}"> <!-- format links -->
<se:rowformat>
<li><a href="{this.location()}">{this.name()}</a></li>
</se:rowformat>
<se:resultformat>
<ul>{this.result()}</ul>
</se:resultformat>
</se:format>
|
|