I have a property IsValid in Document Type with type set to true/false. Now I want to check this value in my xslt and branch the functionality accordingly. How do I do this........my code always retruns false and does not branch out. I would appreciate if someone could provide me the code f/else condition.
Here are some code samples that I found in the forums and have tried and failed
Hmm.... A true/false property should return either 0 or 1 if you have published the page. Are you checking this inside a loop of some kind? I'm asking because you are not having $currentPage in the code from your recent post.
If you're inside a loop, it would also make sense that $currenPage/IsValid doesn't return 0 or 1.
I always use the not(propertyName = 1) version - also when checking umbracoNaviHide. It safeguards against the case where the property doesn't even exist on a Document (whether because it hasn't got it, or because it hasn't been published since it got it).
Kim's point is important - that you need $currentPage if not inside a loop or matching template.
The reason for why 0 was not displayed was because once a new property is created the content has to be published, which I did not do because I thought the checkbox was to remain unchecked and so I did not bother publishing it ......................my mistake.
I am inside the loop and hence not $currentPage.
Thanks for the so many quick responses. I did learn something new today..........Thanks......guys!
If condition and bool property
I have a property IsValid in Document Type with type set to true/false. Now I want to check this value in my xslt and branch the functionality accordingly. How do I do this........my code always retruns false and does not branch out. I would appreciate if someone could provide me the code f/else condition.
Here are some code samples that I found in the forums and have tried and failed
<xsl:if test="IsValid ">
<xsl:if test="string(data [@alias=IsValid ]) = '1'">
<xsl:if test="string($currentPage/data [@alias=IsValid ]) = '1'">
Thanks.
Hi
Try this small snippet:
/Kim A
It always returns true no mater check for '1' or '0'.
Thanks.
It works
<xsl:if test="not(isValid='1')">
do your stuff here
</xsl:if >
If the value is checked then IsValid returns '1' else NULLis returned.
Hmm.... A true/false property should return either 0 or 1 if you have published the page. Are you checking this inside a loop of some kind? I'm asking because you are not having $currentPage in the code from your recent post.
If you're inside a loop, it would also make sense that $currenPage/IsValid doesn't return 0 or 1.
/Kim A
Could you perhaps share the XML output with us? This behaviour sounds a bit odd to me as well.
What version of Umbraco are you using?
/Jan
Hi,
I always use the not(propertyName = 1) version - also when checking umbracoNaviHide. It safeguards against the case where the property doesn't even exist on a Document (whether because it hasn't got it, or because it hasn't been published since it got it).
Kim's point is important - that you need $currentPage if not inside a loop or matching template.
/Chriztian
My umbraco version 4.5.2
The reason for why 0 was not displayed was because once a new property is created the content has to be published, which I did not do because I thought the checkbox was to remain unchecked and so I did not bother publishing it ......................my mistake.
I am inside the loop and hence not $currentPage.
Thanks for the so many quick responses. I did learn something new today..........Thanks......guys!
is working on a reply...