If that is correct you could simply query for that alttemplate (in both cases) in your Xslt File like this: umbraco.library:HttpItem('altTemplate') and then create a xslt:when to determine which template is used.
The umbraco requestHandler takes care of checking if there is a template specified in your url and then adds this to the HttpContext.Items which you can access through the library function HttpItem.
I'm sorry the library Function is called GetHttpItem so this should give you the correct results:
<xsl:choose> <xsl:when test="umbraco.library:GetHttpItem('altTemplate') = 'fancy'"> <!-- Do your fancy rendering --> </xsl:when> <xsl:when test="umbraco.library:GetHttpItem('altTemplate') = 'text'"> <!-- Do your text rendering --> </xsl:when> <xsl:otherwise> <!-- Do nothing --> </xsl:otherwise> </xsl:choose>
Macro/xslt - rendering depending on used template
Okay let me try and explain. Hope it makes sense.
In the editor I will insert an macro, for example "Current Weather" that gets the current weather from a location set by a macro parameter.
I then need to have two types of final output/templates: Fancy and Text.
Right now I am thinking of making two templates:
- Fancy: Super-cool weather status with graphics (clouds, sun, rain etc.)
- Text: Example - Sunny, 24 C
URLs with alternative templates
.../weather/fancy.aspx
.../weather/text.aspx
How do I in the macro/xslt test wich template is in use ?
Or should I do it in another way ?
Thanks in advance
Mikkel
Maybe the answer is here http://our.umbraco.org/forum/developers/xslt/1764-testing-against-active-template-name-[solved]
Hi,
since you only specify the page wether in your cms calls to
.../weather/fancy.aspx
.../weather/text.aspx
are the same as calls to
.../weather.aspx?alttemplate=fancy
.../weather.aspx?alttemplate=text
If that is correct you could simply query for that alttemplate (in both cases) in your Xslt File like this: umbraco.library:HttpItem('altTemplate') and then create a xslt:when to determine which template is used.
The umbraco requestHandler takes care of checking if there is a template specified in your url and then adds this to the HttpContext.Items which you can access through the library function HttpItem.
Hope this helps
Toby
I'm sorry the library Function is called GetHttpItem so this should give you the correct results:
<xsl:choose>
<xsl:when test="umbraco.library:GetHttpItem('altTemplate') = 'fancy'">
<!--
Do your fancy rendering
-->
</xsl:when>
<xsl:when test="umbraco.library:GetHttpItem('altTemplate') = 'text'">
<!--
Do your text rendering
-->
</xsl:when>
<xsl:otherwise>
<!--
Do nothing
-->
</xsl:otherwise>
</xsl:choose>
Thanks Toby
I will try it, and I all-ready believe that it will do the job.
-Mikkel
is working on a reply...