I have a macro which selects events from pdcalendar and displays a nicely formatted list of upcoming ones.
We recently ran into an issue whereby it will, after displaying about 11 events, for some reason, skip over a closing <div> tag and cause the next item to appear within the previous. This then occurs approximately every four items.
I can't see anything in my code which would cause this, so I'm at a loss.
Hey Geoff, If your logic causes an empty <div></div> to be created like so without any inner content the XSLT will create the div like so <div /> which cause browser inconsistencies.
So the easiest way is to switch the XSLT file from XML to HTML at the top of the file.
Looping error causing nesting
Hi all,
I have a macro which selects events from pdcalendar and displays a nicely formatted list of upcoming ones.
We recently ran into an issue whereby it will, after displaying about 11 events, for some reason, skip over a closing <div> tag and cause the next item to appear within the previous. This then occurs approximately every four items.
I can't see anything in my code which would cause this, so I'm at a loss.
<xsl:for-each select="$currentPage/Event [umbraco.library:DateGreaterThanOrEqualToday(./pdcalendarevent/pdcalendarevent/pdcstart)]">
<xsl:sort select="current()/pdcalendarevent/pdcalendarevent/pdcstart"/>
<div class="event_1_main">
<div class="event_img">
<xsl:copy-of select="$currentPage/data[@alias='eventImage/umbracoFile']"/>
<a href="{umbraco.library:NiceUrl(current()/@id)}"><img src="{umbraco.library:GetMedia(current()/eventImage, true())/umbracoFile}" alt="" border="0"/></a>
</div>
<div class="event_right_part">
<h2 class="event_title"><xsl:value-of select="current()/mainContentTitle"/></h2>
<div class="event_text">
<strong><xsl:value-of select="umbraco.library:FormatDateTime(current()/pdcalendarevent/pdcalendarevent/pdcstart, 'D')"/></strong>
<br />
<xsl:value-of select="umbraco.library:TruncateString(current()/eventDescription, number(275), '...')" disable-output-escaping="yes"/>
</div>
<div class="viewmore_btn"><a href="{umbraco.library:NiceUrl(current()/@id)}">More Information</a></div>
</div>
</div>
</xsl:for-each>
Hey Geoff,
If your logic causes an empty <div></div> to be created like so without any inner content the XSLT will create the div like so <div /> which cause browser inconsistencies.
So the easiest way is to switch the XSLT file from XML to HTML at the top of the file.
<xsl:output method="xml" omit-xml-declaration="yes"/>
Needs changing to
<xsl:output method="html" omit-xml-declaration="yes"/>
Hi, Geoff,
As Warren says, some browsers don't render a self-closed <div /> gracefully. You've got two options:
doug.
I don't understand where the issue is, there is no reason there should be an empty tag, and changing the output method does not fix the issue.
Hey Geoff,
Can you provide more speicifcs to the problem.
As in which part of the code is causing the empty <div> to be outputted to the page?
Then we can try and figure out what is causing it.
Hey guys,
Turns out it was a completely different mistake.
umbraco.library:TruncateString(current()/eventDescription, number(275), '...')
Operated on rich-text content, meaning there were potentially HTML tags being opened, but never closed. This has now been corrected to;
umbraco.library:TruncateString(umbraco.library:StripHtml(current()/eventDescription), number(275), '...')
And is working correctly.
-Geoff
is working on a reply...