Cached sitemap with personalization

The sitemap macro has a minimumbrowselevel parameter for showing restricted content when users are logged on.

However, when you use a sitemap in standard user-interface elements such as collapsible html menus, you may wish to cache the sitemap macro to minimize the overhead the menu causes.

You will find that simply wrapping the sitemap macro in a cache macro is not feasible in this situation, because the cache knows nothing about the current login status and you will end up with a sitemap that doesn't reflect the current user's browse access rights.

The following example provides a solution to this problem.

Smartsite SXML CopyCode image Copy Code
<se:cache save="cache = this.getcachekey()" resulttype="none">
       <se:sitemap startitem="META_NAVIGATION" resulttype="datatable" maxlevels="2" />
</se:cache>

<se:xlinks inputdata="cache" minimumbrowselevel="100">
       <se:parameters>
              <se:parameter name="format">
                     <se:rowformat>
                           <li>
                                  <a href="{channel.link(this.field(nr))}">{this.field(title)}</a>
                                  {this.childlevelresult()}
                           </li>
                     </se:rowformat>
                     <se:levelformat groupby="this.field(level)">
                           <ul>{this.levelresult()}</ul>
                     </se:levelformat>
              </se:parameter>
       </se:parameters>
</se:xlinks>