Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin 278 posts 662 karma points
    Nov 01, 2011 @ 20:31
    Martin
    0

    "and" Operator Issue - Macro Container Umbraco TV tutorial

    Hi, Im going through the Umbraco TV tutorials and I have come across an issue with my macro and the "and" operator.

    I have created the macro parameters and inserted the macro into the template.

    But I am not getting any values back with the and operator. I can get a single value back from one variable when i remove the "and".

    I am still learning xslt, so any help would be grateful.

    Thanks

    Martin

    My xslt macro is:

    <xsl:param name="currentPage"/>
        <xsl:variable name="title" select="/macro/title"/>
        <xsl:variable name="text" select="/macro/text"/>


      <xsl:template match="/">
      <!-- start writing XSLT -->
         <div
     
          <xsl:if test="$title and $text">
            <h4><xsl:value-of select="$title"/></h4>
            <p><xsl:value-of select="$text"/></p>
          </xsl:if>  
           
        </div>
    </xsl:template> 
  • Martin 278 posts 662 karma points
    Nov 01, 2011 @ 21:30
    Martin
    0

    It's not the "and" operator that is causing the issue. I found out that the word "text" as a variable title causes issues.

    Ive tried it with a few titles and it only seems to fail when i use the word "text"

    Anyone else have issues like this.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 02, 2011 @ 00:16
    Chriztian Steinmeier
    0

    Hi Martin,

    I know "class", "width" and "height" are prone to error too - even so, the error is solely a .NET error. You can name your variable "text" alright - you just can't use "text" as the name of the macro parameter, because you'll need to put an attribute with that name on the <umbraco:macro> tag, where it's apparently reserved for use by .NET... a workaround that lets you keep the "text" name in XSLT would be like this:

    <!-- Template -->
    <umbraco:macro alias="MyMacro" textparam="Here I am" runat="server" />
    
    <!-- XSLT -->
    <xsl:variable name="text" select="/macro/textparam" />

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft