Developer forum

Forum » Templates » The use of [@If Defined]

The use of [@If Defined]


Reply

Hi

 

Is there a way to use the IF to test if a page has a given page ID of if a menu has any content?

 

ex:

           < !--@If Defined(DwPageID==2702)-- >

OR can the only be used to tell if a variabel has a value.


Replies

 
Reply

The 'If Defined' can only tell you if a tag is available or not.

 

// Sebastian

 
Reply

My issue is that I have a top menu 1. niv, and have a left menu on the 2. niv.

 

This is how I have tried to solve it, but i doses not work.

 

 

<div class="content">
        <!--@If Defined(DwPageID==2702)-->
        <div style="float:left;">
        <!--@2ni
        </div>
        <!--@EndIf(DwPageID==2702)-->
        <!--@DwContent-->
</div>

Do you have a way to get this to work :)

 
Reply

I would definately go for an XSLT template instead.

 

That would be the only way to check for a specific ID unless you wanna use Javascript.

 

// Sebastian

 
Reply

Super.

 

 

I just converted the templeate using the button in hte editor.

 

 

And after a litle ajustment, I got this :)

 

 

 

<

div class="content">xsl:if test="DwPageID!=2702">div style="float:left;">xsl:value-of select="leftmenu" disable-output-escaping="yes"/>div>xsl:if>xsl:value-of select="DwContent" disable-output-escaping="yes"/>div>

 

Thanks for pointing i the right direction

<

<

<

</

</

<

</

 

 
Reply

Super.

I just converted the templeate using the button in hte editor.

 

And after a litle ajustment, I got this :)

 

<div class="content">
  <xsl:if test="DwPageID!=2702">
    <div style="float:left;">
      <xsl:value-of select="leftmenu" disable-output-escaping="yes"/>
    </div>
  </xsl:if>
  <xsl:value-of select="DwContent" disable-output-escaping="yes"/>
</div>


Thanks for pointing i the right direction
 

 
Reply

Hello,

I've just tryed this and it did not work 4 me :(

 <xsl:if test="DwPageID!=10142">

         <xsl:attribute name="href"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
        <xsl:value-of select="@MenuText" disable-output-escaping="yes"/>
        </xsl:if>

and

 <xsl:if test="DwPageID=10142">

         <xsl:attribute name="href"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
        <xsl:value-of select="@MenuText" disable-output-escaping="yes"/>
        </xsl:if>

same result - no output :/

Am I missing something here?

 
Reply
Hi Rasmus

Try doing like this:

<xsl:if test="DwPageID != '12345'">
    Do something
</xsl:if>

Maybe you should also look at the <xsl:choose> structure.

// Sebastian

 

You must be logged in to post in the forum