Placeholder Example

With help of a SQLQuery macro, a list of all items in the contents table is created. This list is grouped by contenttype. A Placeholder macro is used to create a container. This container is filled when formatting the rows of the sqlquery macro. The placeholder is formatted as a list of all contenttypes with the amount of items of that contenttype. This result is displayed as a list of hyperlinks with bookmarks, directing to the right place within the formatted result of the sqlquery macro.

Smartsite SXML CopyCode image Copy Code
<se:placeholder id="facettedlist" sortcolumn="contenttype">
    <se:parameters>
        <se:parameter name="fieldnames">
            <se:collection>
                <se:member>Contenttype</se:member>
                <se:member>Nr</se:member>
                <se:member>ContenttypeCode</se:member>
            </se:collection>
        </se:parameter>
        <se:parameter name="format">
            <se:rowformat>
                {this.buffer.set('rowcount',this.buffer.get(rowcount,default=0)+1)}
                {this.buffer.set('contenttypecode',this.field(contenttypecode))}
            </se:rowformat>
            <se:groupformat groupby="this.field(contenttype)">
                <li>
                    <a href="{url.setbookmark(channel.link(itemdata.number()),this.buffer.get(contenttypecode))}">
                        {this.group()} ({this.buffer.get(rowcount)})
                    </a>
                </li>
                {this.buffer.set('rowcount',0)}
            </se:groupformat>
        </se:parameter>
        <se:parameter name="resultformat">
            <a name="top"></a>
            <ul>
                {this.result()}
            </ul>
        </se:parameter>
    </se:parameters>
</se:placeholder>
<se:sqlquery>
    <se:parameters>
        <se:parameter name="sql">
            SELECT c.Nr, c.Title, c.Description, ct.Name, ct.Code
            FROM vwContent c
            JOIN Contenttypes ct ON c.Contenttype=ct.Nr
            ORDER BY ct.Name    
        </se:parameter>
        <se:parameter name="format">
            <se:rowformat>
                {placeholder.add(facettedlist,this.field(name),this.field(nr),this.field(code))}
                {this.buffer.set(ctcode,this.field(code))}
                <tr>
                    <td>{this.field(title)}</td>
                    <td>{this.field(description,default='no description')}</td>
                </tr>
            </se:rowformat>
            <se:groupformat groupby="this.field(name)">
                <h3><a name="{this.buffer.get(ctcode)}"></a>{this.group()}</h3>
                <table>
                    <colgroup>
                        <col width="200px"></col>
                        <col></col>
                    </colgroup>
                    <thead>
                        <tr>
                            <th>Title</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        {this.groupresult()}
                    </tbody>
                </table>
                <a href="{url.setbookmark(channel.link(itemdata.number()),top)}">Back to top</a>
            </se:groupformat>
        </se:parameter>
        <se:parameter name="resultformat">
            {this.result()}
        </se:parameter>
    </se:parameters>
</se:sqlquery>