Release 1.0 - ...
Sometimes, it would be nice if we could manipulate the rendering of DataTable macros such as XLinks from other parts of the SXML being rendered, without depending on the actual calling order in the SXML. Imagine for instance that you have an XLinks macro in your Render Template and you want to be sure you can manipulate its data in any other part of the SXML being rendered, then display the final formatted result.
As we all know, the placeholder macro was designed to do just that. Also, the placeholder macro internally hosts a DataTable and supports formatting in exactly the same way. So, wouldn't it be nice if we could use a placeholder to hold the XLinks data and then format it after we've done some more processing, such as adding or removing a few links?
The key to doing this is store the DataTable output of the XLinks macro and use it as inputdata for a placeholder. Then, copy the formatting (default formatting of the XLinks macro is just fine) to the placeholder using the importformat method.
Smartsite SXML |
Copy Code
|
<se:xlinks
parent="sampledata"
resulttype="none"
save="data = this.result(datatable)"
id="xl"
/>
<se:placeholder id="links" sortcolumn="Title" inputdata="data" format="{this.importformat(xl)}" />
|
Now, we're ready to add some links:
Smartsite SXML |
Copy Code
|
{page.links.add(206, 'My favorite page')}
{page.links.add(2, ' Go back Home')}
|
We can even add complete DataTables from other sources:
Smartsite SXML |
Copy Code
|
<se:xlinks parent="206" resulttype="datatable" resultformat="{page.links.append(this.result())}" />
|
Another scenario would be that under circumstances, you want to suppress the rendering of the XLinks:
Smartsite SXML |
Copy Code
|
{page.links.clear()}
|
Of course, the real world scenario here would be that the first piece of code would reside in a RenderTemplate or a System Translation. The point is simply that you can achieve delayed rendering