Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi All,
I have the following XSLT code:
<?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:for-each select="$currentPage/ancestor-or-self::* [name()='Event' and umbraco.library:DateGreaterThanOrEqualToday(./eventDate)]"><div class="event_1_main"> <div class="event_img"><img src="/images/event_img_2.jpg" alt="" /></div> <div class="event_right_part"> <h2 class="event_title"><xsl:value-of select="current()/@nodeName"/></h2> <div class="event_text"> <strong><xsl:value-of select="current()/eventDate"/></strong><br /> <xsl:value-of select="current()/eventDescription"/> </div> <div class="viewmore_btn"><a href="{umbraco.library:NiceUrl(current()/@id)}">VIEW MORE</a></div> </div></div></xsl:for-each></xsl:template></xsl:stylesheet>
and it displays nothing on my page. What is the correct way to select child elements of the current page by type?
I will also need to perform a similar selection in another piece of code, so how does one select elements from under a specific node?
Hi Geoff,
Try this slight refactoring for a simple way to illustrate this:
<xsl:template match="/"> <xsl:apply-templates select="$currentPage/ancestor-or-self::Event[umbraco.library:DateGreaterThanOrEqualToday(eventDate)]" /> </xsl:template> <!-- Template for an Event node --> <xsl:template match="Event"> <div class="event_1_main"> <div class="event_img"> <img src="/images/event_img_2.jpg" alt="" /> </div> <div class="event_right_part"> <h2 class="event_title"> <xsl:value-of select="@nodeName"/> </h2> <div class="event_text"> <strong> <xsl:value-of select="eventDate"/> </strong> <br /> <xsl:value-of select="eventDescription"/> </div> <div class="viewmore_btn"> <a href="{umbraco.library:NiceUrl(@id)}">VIEW MORE</a> </div> </div> </div> </xsl:template>
Note that once you're inside a template (or a for-each for that matter) you can just refer to child elements without any prefix (current() or ./ etc.) at all.
/Chriztian
Alright, thanks for your help.
I'm having trouble getting an image to display in this loop.
<img src="{umbraco.library:GetMedia(current()/eventImage, true())}" alt="" />
Gives me "/media/15926/banner.jpg67326887970jpg" - "67326887970jpg" should not be there. What am I doing wrong?
Thanks.
Seems like you are picking the image from the media secion. You could try this chaging this
<imgsrc="{umbraco.library:GetMedia(current()/eventImage, true())}"alt=""/>
to
<img src="{umbraco.library:GetMedia(eventImage, 'true')/umbracoFile}" alt=""/>
//fuji
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Looping and page selection in XSLT problem
Hi All,
I have the following XSLT code:
<?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:for-each select="$currentPage/ancestor-or-self::* [name()='Event' and umbraco.library:DateGreaterThanOrEqualToday(./eventDate)]">
<div class="event_1_main">
<div class="event_img"><img src="/images/event_img_2.jpg" alt="" /></div>
<div class="event_right_part">
<h2 class="event_title"><xsl:value-of select="current()/@nodeName"/></h2>
<div class="event_text">
<strong><xsl:value-of select="current()/eventDate"/></strong><br />
<xsl:value-of select="current()/eventDescription"/>
</div>
<div class="viewmore_btn"><a href="{umbraco.library:NiceUrl(current()/@id)}">VIEW MORE</a></div>
</div>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
and it displays nothing on my page. What is the correct way to select child elements of the current page by type?
I will also need to perform a similar selection in another piece of code, so how does one select elements from under a specific node?
Hi Geoff,
Try this slight refactoring for a simple way to illustrate this:
Note that once you're inside a template (or a for-each for that matter) you can just refer to child elements without any prefix (current() or ./ etc.) at all.
/Chriztian
Alright, thanks for your help.
I'm having trouble getting an image to display in this loop.
<img src="{umbraco.library:GetMedia(current()/eventImage, true())}" alt="" />
Gives me "/media/15926/banner.jpg67326887970jpg" - "67326887970jpg" should not be there. What am I doing wrong?
Thanks.
Hi Geoff,
Seems like you are picking the image from the media secion. You could try this chaging this
<imgsrc="{umbraco.library:GetMedia(current()/eventImage, true())}"alt=""/>
to
<img src="{umbraco.library:GetMedia(eventImage, 'true')/umbracoFile}" alt=""/>
//fuji
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.