Copied to clipboard

Flag this post as spam?

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


  • Stef 3 posts 53 karma points
    Jul 09, 2013 @ 12:17
    Stef
    0

    problem with a small xslt checkbox check

    Hello guys!

    I am currently working with Umbraco 4.0.4.2 (i know really old, it will be updated in the future) and i wanted to add a checkbox to the newsitem pages so the editors can add social media buttons to the page where they would like to have them.

    Now my problem is that i thought i had solved it by making a xslt macro that gets the checkbox and if it is 1 then add the div with the social media items to the page. this is my xslt script:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <xsl:variable name="buttons" select="string($currentPage/data [@alias='addSocialMediaButtons'])" />

    <xsl:if test="string($buttons) = '1'" >
    <div id="TestSocialMedia">
    <br/><br/>
    </div>
    </xsl:if>

    </xsl:template>

    </xsl:stylesheet>


    So i checked if it was 1 (checked) and if it is then just show the div. but the variable is empty.
    My question was, why is it empty in the first place? I already checked my alias 2 times so that isn't the problem

    Any suggestions in how to fix this easy problem?

    Keep in mind that this is 4.0.4.2

    Thanks in advance!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 09, 2013 @ 16:06
    Jan Skovgaard
    0

    Hi Stef and welcome to our :)

    This may be a stupid question on my behalf but did you hit "Save and publish" on the node, on which you're testing? If so do you see a value on the node if you have a look in the /data/umbraco.config file and search for "addSocialMediaButtons"? - If it has a value of 1 in there then it must be something in the syntax but at a first glance it looks fine to me.

    Looking forward to hearing from you.

    /Jan

  • Stef 3 posts 53 karma points
    Jul 09, 2013 @ 17:08
    Stef
    0

    Hello Jan!

    It's not a stupid question but yes i had hit save and publish on the node. I also tried to print a value to maybe see if it returned 0 but that didn't work either. I can't reach the config file from my location at this point yet but tomorrow i probably will so i will have a look at that then. It's really confusing to me because it is just a simple check if the checkbox is checked. It seems to not find the checkbox at all.

     

    thank you for your reaction.

  • Stef 3 posts 53 karma points
    Jul 10, 2013 @ 09:09
    Stef
    100

    ok I solved it but I didn't see how i fixed it.
    All I did was copy an existing xslt template and edited that to what i already had. so basically didn't change anything and now it works.

    So yea i have no idea what actually went wrong in the first place but thanks for helping!

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 10, 2013 @ 09:40
    Jan Skovgaard
    0

    Hi Stef

    Glad to hear you managed to got it working - Even if it means it was magic ;-)

    Happy umbracoing.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft