Im working on a simple little XSLT script to allow my editors to include (or not) a YouTube video panel on the page. By default I want it to be set to display the video section, but if my editor would like to hide it, they can simply "check off" the hide option in the admin and it will be removed for that page.
Here's a screenshot:
I created a True/False datatype (youTubeShow) and would like to have a statement like.
If on the current page "youTubeShow" = 0, then display (html code here), else display nothing.
I suppose you should be able to fetch the content like...
<xsl:if test="$currentPage/youTubeShow != '1'>
<!-- your code goes here --->
</xsl:if>
Isn't this what you're after?
By the way I think you should change the alias to youTubeHide since that is what this property should do, right? It's a bit confusing that it's named "Show" when it's supposed to hide stuff when it has been checked - just nitpicking I know...:-)
As Jan said really, althout I'd probably question whether you need the boolean at all. Why not just check whether there is a youtube video URL entered? If there is one, show the video, else don't. Should save you an extra click at least.
<xsl:if test="string-length($currentPage/youTubeUrl) > 0">
<!-- insert video player code here -->
</xsl:if>
@Jan - Thanks. I think I was making it more complicated than it needed to be.. you answers works just fine. and your right about changing the name to Hide.. good call
@Matt - this video section is going to be a recursive element, so in this case using a true/false value will work out better for me since a video is not really declared on each page. But thanks for the suggestion
XSLT - If Statement - To Show Content (or not)
Hello Everyone,
Im working on a simple little XSLT script to allow my editors to include (or not) a YouTube video panel on the page. By default I want it to be set to display the video section, but if my editor would like to hide it, they can simply "check off" the hide option in the admin and it will be removed for that page.
Here's a screenshot:
I created a True/False datatype (youTubeShow) and would like to have a statement like.
If on the current page "youTubeShow" = 0, then display (html code here),
else display nothing.
Hi FFC
I suppose you should be able to fetch the content like...
<xsl:if test="$currentPage/youTubeShow != '1'>
<!-- your code goes here --->
</xsl:if>
Isn't this what you're after?
By the way I think you should change the alias to youTubeHide since that is what this property should do, right? It's a bit confusing that it's named "Show" when it's supposed to hide stuff when it has been checked - just nitpicking I know...:-)
/Jan
Hey FFC,
As Jan said really, althout I'd probably question whether you need the boolean at all. Why not just check whether there is a youtube video URL entered? If there is one, show the video, else don't. Should save you an extra click at least.
Cheers
Matt
Do'h, off course! If the string is empty...no video is shown...should have caught that one myself :D
/Jan
@Jan - Thanks. I think I was making it more complicated than it needed to be.. you answers works just fine. and your right about changing the name to Hide.. good call
@Matt - this video section is going to be a recursive element, so in this case using a true/false value will work out better for me since a video is not really declared on each page. But thanks for the suggestion
is working on a reply...