Copied to clipboard

Flag this post as spam?

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


  • Matias Korn 30 posts 49 karma points
    Jun 06, 2012 @ 15:18
    Matias Korn
    0

    ToggleBox

    Hello everybody.

    I was looking for a true false with a default value and i found out that togglebox was just what i need. I can access the value through umbraco:item inside template without anyproblem, but for some reason inside xslt the value wont return.
    I use this code:

    <xsl:value-of select="$currentPage/umbracoNaviHide"/>

    If i use this command for getting the @nodeName i get it without the problem så the param $currentPage is not the problem.

    <xsl:value-of select="$currentPage/@nodeName"/>

    I have double checked the name and it is correct.

     

    I realy cant find a solid reason for why i cant get the value.

  • Nigel Wilson 945 posts 2077 karma points
    Jun 07, 2012 @ 02:40
    Nigel Wilson
    0

    Hi Matias

    Just a guess...

    Maybe the value is null and therefore will never return a value. What I mean by that is: have you ticked the tick box and then check to see if a value is output. And then untick it, republish and again check if a value is output. In this case it might be "0" due to the changes made. But it you have never changed the value since creating the node it mgiht be null. 

    So maybe in your xslt you could try this (not sure this is the most efficient but it may solve the problem):

    <xsl:variable name="myvariable">
    <xsl:choose>
    <xsl:when test="string($currentPage/umbracoNaviHide) = '1')>
    <xsl:value-of select="'1'" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="'0'" /> 
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    <xsl:value-of select="$myvariable" /> 

    Good luck.

    Cheers

    Nigel

     

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Jun 17, 2012 @ 23:09
    Dan Okkels Brendstrup
    0

    Nigel is right, the togglebox property doesn't contain/output a value in the XML until it has been set. This is different than the checkbox property, which is often used for umbracoNaviHide, which outputs "0" by default, and "1" when checked.

    So when you use the value in a predicate to only output non-hidden pages, simply do it like this:

    <xsl:apply-templates select="Page[not(umbracoNaviHide = 1)]"/>

    ...which will work regardless of whether the value is "0" or not set at all.

    I don't know if you've tried it, but Chriztian's XMLDump package is great for debugging this kind of thing, when you need to see the XML that you are working with.

  • Matias Korn 30 posts 49 karma points
    Jun 18, 2012 @ 00:22
    Matias Korn
    0

    I found out that it was like everything else in umbraco, that already existing documents or nodes in the content tree will stay null and not 1. New documents will have a default value of 0.

  • Dan Okkels Brendstrup 101 posts 197 karma points
    Jun 18, 2012 @ 08:18
    Dan Okkels Brendstrup
    0

    Right — and if you right-click the Content node and select "Republish entire site", they should all get a value.

    But in any event, the above mentioned method of handling umbracoNaviHide works for both non-existing values and any value other than "1".

Please Sign in or register to post replies

Write your reply to:

Draft