Getting started with portal-functions
You will need to upgrade Vertical Site to 4.1.x to get access to our new portal-functions.
Create Google-friendly menues
In your menu.xsl you have to include our portal namespace:
xmlns:portal="http://www.enonic.com/cms/xslt/portal"
You should use this namespace in all your templates from now on, it can get handy for several reasons.
To create an simple menu just call the portal function from the menuitem-node like this:
<xsl:template match="/">
<xsl:if test="/verticaldata/menues/menu/menuitems/menuitem">
<ul id="nav">
<xsl:apply-templates select="/verticaldata/menues/menu/menuitems/menuitem"/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="menuitem">
<li><a href="{portal:createPageUrl(@key,())}"><xsl:value-of select="name"/></a></li>
</xsl:template>
Remember that this last template is very simplyfied. You need to check what kind of menuitem type this is. If this menuitem is of type URL you can not use this approach.
Portal links in an article list
If you have an object using the getContentBySection method you can safely use the portal function.
A simplyfied example:
<xsl:template match="/">
<xsl:if test="/verticaldata/contents/content">
<div class="articleList">
<xsl:apply-templates select="/verticaldata/contents/content"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="content">
<div class="article">
<h1><a href="portal:createContentUrl(@key,())"><xsl:value-of select="title"/></a></h1>
<xsl:if test="contentdata/article/preface/text()">
<p class="preface"><xsl:value-of select="contentdata/article/preface"/></p>
</xsl:if>
</div>
</xsl:template>
What is the difference between this function and the one used in menu.xsl?
- createPageUrl() - for menuitems
- createContentUrl() - for content that is published to a section or places directly on a page.
The last one is a little tricky because you can't find it in the output XML. You will only find important XML when you have published your content to a section.




Comments
If you want to comment on this article you need to be logged in.