The xsl does not write out the </a> tag causing the gallery to stop working in IE.
Hi!
I am using "galleriffic" (http://www.twospy.com/galleriffic/index.html) to show some pictures (great gallery by the way). It wants to have a ul list with all the content that should be shown in the slideshow. It works fine when I hard code the ul list in the template with the li looking like this:
As you can see the xsl has chosen to leave out the </a> tag (look at the first row) and without it the gallery does not work. I have seen that this is the problem because if I write <a class="thumb" name="leaf" href="/media/8773/2_b.jpg" title="Picture one" /> in hard coded li in the template it gives the same problem.
SO, does anyone know how to make the xsl write out the </a> tag so that IE gets happier? :)
None of them makes any difference to the output, stil gets <a stuff /> instead of <a stuff></a> :(
Any more ideas?
(also I am wondering about a thing that I simply do not understand. When I use things like this gallery or jCarusel, where jQuery scripts have to be imported into the master template. FF does not seem to find the script unless it is imported directly into the xsl. In IE there is no problem. I can use the example code given, no problems. But as soon as I get the html through the xsl, FF can't find the script-tags unless they are in the xsl file.
I do not have the same problem otherwise (have a superfish menu that works just fine without importing the script to the xsl). I can generate html through xsl and then just add script-tags to the master template and it works. Are there any special rules to follow when importing script-tags? )
The problem here is that XSLT will automatically close a tag that has nothing in it. That's the spec and it is doing what it is supposed to do. You have three options:
1. Put something in the tag for the anchor to display (<a href="#">something-here</a>)
Okej, now (sitting in China at the moment, so I am 7h away) I have tried to write as Nik said, but it did not work and I am not sure of how to change the XSLT output method html. It complains on the attribute - method then. So then I tried to write:
<li> <!-- use xsl:text to keep xslt from shortening the A tag --> <xsl:text disable-output-escaping="yes"><a class="thumb" name="leaf" href="</xsl:text> <xsl:value-of select="data[@alias='topicUploadPicture']"/> <xsl:text disable-output-escaping="yes">" title="</xsl:text>
So that is great. But for some reason it simply does not work in IE6 and Safari (in IE6 the buttons does not work and in Safari there is no image). It is a little bit hard to explain. But when I take the output given by the macro and use that instead of the macro (just to try :) ) in the template, it works in IE6, IE7, Safari and FF (have not tried in Opera, Maxthon or Crome). BUT as soon as I use the macro (even though the output is the same) it does not work!
<xsl:choose> <xsl:when test="count($currentPage/node [@nodeTypeAlias='sdeerTopicItem']) <= 0"> <div id="noTopicImages"> There are no beautiful photos to show yet... </div> </xsl:when> <xsl:otherwise> <xsl:for-each select="$currentPage/node[@nodeTypeAlias='sdeerTopicItem']">
<li> <!-- use xsl:text to keep xslt from shortening the A tag --> <xsl:text disable-output-escaping="yes"><a class="thumb" name="leaf" href="</xsl:text> <xsl:value-of select="data[@alias='topicUploadPicture']"/> <xsl:text disable-output-escaping="yes">" title="</xsl:text>
There are a couple ways to handle this depending on your needs.
1. Change the docType property to be a 'text multiline' rather than a richtext editor. You won't have wysiwyg editing but you also won't get extraneous markup. (you'll want to review all the pages with a topicRichTextDescription field to clean out any 'extra' markup)
2. Strip off the surrounding <p> tags with the umbraco.library:RemoveFirstParagraphTag() function, like this:
Or, if you want to retain the paragraph tag, you could eliminate any margins or padding by applying the following style rule:
.image-desc p { margin: 0; padding: 0;}
Of course, you may have other reasons for not wanting the p tag in there. If so, I would vote for Dougs 1st suggetion in the above post, change the property on your docType (since you don't want/need the author to apply any style or markup to the content).
Hi! Thank you for all your answers! I have been away to Beijing over the new year, so I am sorry for not writing until now.
Once I got the xsl to do what I wanted the slideshow stil did not work in IE and Safari. But we had placed the jQuery script tag in two locations to make FF find it (in the xsl and in the template). So just now I commented the script tag in the template and now it works in Safari, IE 6 and 7, FF and in Maxthon.. woohoo!! :D
The xsl does not write out the </a> tag causing the gallery to stop working in IE.
Hi!
I am using "galleriffic" (http://www.twospy.com/galleriffic/index.html) to show some pictures (great gallery by the way). It wants to have a ul list with all the content that should be shown in the slideshow. It works fine when I hard code the ul list in the template with the li looking like this:
<li>
<a class="thumb" name="leaf" href="/media/6999/2_b.jpg" title="Title #0"></a>
<div class="caption">
<div class="image-title">Title #0</div>
<div class="image-desc">Description</div>
</div>
</li>
I want the users to be able to add the photos themselves and therefore I create the same li items through a xsl. Like this:
<xsl:for-each select="$currentPage/node[@nodeTypeAlias='topicItem']">
<li>
<a class="thumb" name="leaf" title="Title #0">
<xsl:attribute name="href">
<xsl:value-of select="data[@alias='topicUploadPicture']"/>
</xsl:attribute>
</a>
<div class="caption">
<div class="image-title"><xsl:value-of select="data[@alias='topicTextStringTitle']"/></div>
<div class="image-desc"><xsl:value-of select="data[@alias='topicRichTextDescription']" disable-output-escaping="yes" /></div>
</div>
</li>
</xsl:for-each>
This will give an output in the template like this:
<li>
<a class="thumb" name="leaf" href="/media/8773/2_b.jpg" title="Picture one" />
<div class="caption">
<div class="image-title">Picture one</div>
<div class="image-desc"><p>Description for picture one</p></div>
</div>
</li>
As you can see the xsl has chosen to leave out the </a> tag (look at the first row) and without it the gallery does not work. I have seen that this is the problem because if I write <a class="thumb" name="leaf" href="/media/8773/2_b.jpg" title="Picture one" /> in hard coded li in the template it gives the same problem.
SO, does anyone know how to make the xsl write out the </a> tag so that IE gets happier? :)
Hi,
Have you tried added a blank space?
I.e.
It's a bit of a hack but it might work for you?
Cheers,
Chris
Or instead of a blank space, what I tend to do is a non breaking space:
Oh.. well that didn't come out as it should have.. It said & n b s p ; (without the spaces!) in the <xsl:text> element.
Hi!
Thank you for helping me!
Ok, I have now tested to write:
<a class="thumb" name="leaf" title="Title #0">
<xsl:attribute name="href">
<xsl:value-of select="data[@alias='topicUploadPicture']"/>
</xsl:attribute>
</a>
And:
<a class="thumb" name="leaf" title="Title #0"><xsl:attribute name="href"><xsl:value-of select="data[@alias='topicUploadPicture']"/></xsl:attribute></a>
None of them makes any difference to the output, stil gets <a stuff /> instead of <a stuff></a> :(
Any more ideas?
(also I am wondering about a thing that I simply do not understand. When I use things like this gallery or jCarusel, where jQuery scripts have to be imported into the master template. FF does not seem to find the script unless it is imported directly into the xsl. In IE there is no problem. I can use the example code given, no problems. But as soon as I get the html through the xsl, FF can't find the script-tags unless they are in the xsl file.
I do not have the same problem otherwise (have a superfish menu that works just fine without importing the script to the xsl). I can generate html through xsl and then just add script-tags to the master template and it works. Are there any special rules to follow when importing script-tags? )
Thank you!
The only other thing I would suggest is using the following syntax:
HTH,
Nik
Oh, one more thing....make sure your output type is set to HTML:
Otherwise, the parser will lop-off empty end tags.
Thanks,
Nik
The problem here is that XSLT will automatically close a tag that has nothing in it. That's the spec and it is doing what it is supposed to do. You have three options:
1. Put something in the tag for the anchor to display (<a href="#">something-here</a>)
2. Change the XSLT's output method to "html". This has other ramifications so consider it carefully. (see the section about 'XSL output method' at http://blog.percipientstudios.com/2009/4/11/anatomy-of-an-umbraco-xslt-file.aspx)
3. Get a little creative and force XSLT to output the text you really want:
cheers,
doug.
Hi again :)
Okej, now (sitting in China at the moment, so I am 7h away) I have tried to write as Nik said, but it did not work and I am not sure of how to change the XSLT output method html. It complains on the attribute - method then. So then I tried to write:
<li>
<!-- use xsl:text to keep xslt from shortening the A tag -->
<xsl:text disable-output-escaping="yes"><a class="thumb" name="leaf" href="</xsl:text>
<xsl:value-of select="data[@alias='topicUploadPicture']"/>
<xsl:text disable-output-escaping="yes">" title="</xsl:text>
<xsl:value-of select="data [@alias = 'topicTextStringTitle']"/>
<xsl:text disable-output-escaping="yes">"></a></xsl:text>
<div class="caption">
<div class="image-title">
<xsl:value-of select="data[@alias='topicTextStringTitle']" disable-output-escaping="yes"/>
</div>
<div class="image-desc">
<xsl:value-of select="data[@alias='topicRichTextDescription']" disable-output-escaping="yes"/>
</div>
</div>
</li>
That gives me the right html output :D (but somehow the discription gets <p> tags!):
<li>
<a class="thumb" name="leaf" href="/media/8773/2_b.jpg" title="Picture one"></a>
<div class="caption">
<div class="image-title">Picture one</div>
<div class="image-desc"><p>Description for picture one</p></div>
</div>
</li>
So that is great. But for some reason it simply does not work in IE6 and Safari (in IE6 the buttons does not work and in Safari there is no image). It is a little bit hard to explain. But when I take the output given by the macro and use that instead of the macro (just to try :) ) in the template, it works in IE6, IE7, Safari and FF (have not tried in Opera, Maxthon or Crome). BUT as soon as I use the macro (even though the output is the same) it does not work!
This is how the whole xsl looks now:
<?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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:value-of select="umbraco.library:AddJquery()"/>
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('', '/scripts/jquery.galleriffic.js')"/>
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('', '/scripts/jquery.opacityrollover.js')"/>
<!-- some code given in the template, but FF does not see it if it is not in here -->
<xsl:value-of select="umbraco.library:RegisterJavaScriptFile('', '/scripts/gallerifficExtra.js')"/>
<xsl:choose>
<xsl:when test="count($currentPage/node [@nodeTypeAlias='sdeerTopicItem']) <= 0">
<div id="noTopicImages">
There are no beautiful photos to show yet...
</div>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$currentPage/node[@nodeTypeAlias='sdeerTopicItem']">
<li>
<!-- use xsl:text to keep xslt from shortening the A tag -->
<xsl:text disable-output-escaping="yes"><a class="thumb" name="leaf" href="</xsl:text>
<xsl:value-of select="data[@alias='topicUploadPicture']"/>
<xsl:text disable-output-escaping="yes">" title="</xsl:text>
<xsl:value-of select="data [@alias = 'topicTextStringTitle']"/>
<xsl:text disable-output-escaping="yes">"></a></xsl:text>
<div class="caption">
<div class="image-title">
<xsl:value-of select="data[@alias='topicTextStringTitle']" disable-output-escaping="yes"/>
</div>
<div class="image-desc">
<xsl:value-of select="data[@alias='topicRichTextDescription']" disable-output-escaping="yes"/>
</div>
</div>
</li>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
(I have the script import in the xsl because for some reason FF does not find the script otherwise. Do not know why... )
Thank you and HAPPY NEW YEAR! :D
You are really close!
The <p> tag is probably coming from the richtext editor. I assume you're using a richtext editor because of the document type alias name.
There are a couple ways to handle this depending on your needs.
1. Change the docType property to be a 'text multiline' rather than a richtext editor. You won't have wysiwyg editing but you also won't get extraneous markup. (you'll want to review all the pages with a topicRichTextDescription field to clean out any 'extra' markup)
2. Strip off the surrounding <p> tags with the umbraco.library:RemoveFirstParagraphTag() function, like this:
3. Strip out all html tags with the umbraco.library:StripHtml() function, like this:
cheers,
doug.
Hi,
Just to add in my example at the top I also put a:
( Without the spaces )
But as with Sebastian's example the forum removes it ;-)
Cheers,
Chris
Or, if you want to retain the paragraph tag, you could eliminate any margins or padding by applying the following style rule:
.image-desc p { margin: 0; padding: 0;}
Of course, you may have other reasons for not wanting the p tag in there. If so, I would vote for Dougs 1st suggetion in the above post, change the property on your docType (since you don't want/need the author to apply any style or markup to the content).
HTH,
Nik
Hi! Thank you for all your answers! I have been away to Beijing over the new year, so I am sorry for not writing until now.
Once I got the xsl to do what I wanted the slideshow stil did not work in IE and Safari. But we had placed the jQuery script tag in two locations to make FF find it (in the xsl and in the template). So just now I commented the script tag in the template and now it works in Safari, IE 6 and 7, FF and in Maxthon.. woohoo!! :D
Thank you again!
is working on a reply...