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:
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
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.
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.
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!
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 " "> ]>
<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!
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
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.
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!
Hi Stef
Glad to hear you managed to got it working - Even if it means it was magic ;-)
Happy umbracoing.
/Jan
is working on a reply...