I guess what confuses me is <xsl:parm name="currentPage"/>. Where am I in the node tree when my xslt is called since I am using <xsl:template match="/">?
I thought that would be at the top of my tree or in my case the node "Content". What basic concept about xpath am I missing?
Check this Gist for an explanation of the way Umbraco provides the context (which at first seems a little strange if you're used to XML & XSLT, but it actually works pretty great for supplying just the context you usually need.)
Thanks for the help! Still alittle confusing, but I'll get it. One problem though, my "featuredImage" from the doctype "NewsArticle" is showing as a broken link. I have the property type as "Media Picker",so they are selected within the "NewsArticle". What should I check? Did I refrence it incorrectly as
That did the trick! Question though, $mediaNode variable that you pull using GetMedia(). What value is it? is it the image itself? or a property that holds all the node data for the image?
Basic Node Refrence
I am haveing a hard time grasping the basic concepts reguarding node selection in xpath. Here is my xml site structure:
Content
Business Site
Company News (doctype = umbNewsArea)
News Article 1 (doctype = NewsArticle) (property = featuredImage)
News Article 2 (doctype = NewsArticle) (property = featuredImage)
News Article 3 (doctype = NewsArticle) (property = featuredImage)
I am trying to refrence the News Articles and select the "featuredImage" property from them to display in a slideshow. Here is my xslt:
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="sliderNode" select="$currentPage/parent::*/child::node/data[@alias=umbNewsArea]"/>
<div id="slider">
<div id="imageSlider">
<xsl:for-each select="$sliderNode/NewsArticle/featuredImage">
<div class="imageSlide">
<div class="imageSliderInfo">
<h2> <xsl:value-of select="@nodeName"/></h2>
<xsl:value-of select="teaserText" disable-output-escaping="yes"/>
</div>
<div class="imageSliderImage">
<img src="{featuredImage}" width="500" height="320" />
</div>
</div>
</xsl:for-each>
</div>
</div>
</xsl:template>
Hi Steve,
It just seems as if you've mixed some legacy schema XPath with some of the new (as of Umbraco 4.5.2 I think) easier schema - try this:
/Chriztian
I guess what confuses me is <xsl:parm name="currentPage"/>. Where am I in the node tree when my xslt is called since I am using <xsl:template match="/">?
I thought that would be at the top of my tree or in my case the node "Content". What basic concept about xpath am I missing?
Hi Steve.
Chriztian has just make a little mistake, missing the $currentPage variable in the siteRoot variable.
Hope this can help you further.
/Dennis
Hi Steve,
Cool you ask that - almost no one does that :-)
Check this Gist for an explanation of the way Umbraco provides the context (which at first seems a little strange if you're used to XML & XSLT, but it actually works pretty great for supplying just the context you usually need.)
/Chriztian
@Dennis: Well spotted, thanks! I'd edit the post if I had the balls, but I've already burned my fingers on that once today, so I'll leave it in :-)
/Chriztian
@Chriztian Thanks a lot. I just spotted it :). You have helped me with some XSLT questions. You are a XSLT genes Chriztian. :)
Chriztian,
Thanks for the help! Still alittle confusing, but I'll get it. One problem though, my "featuredImage" from the doctype "NewsArticle" is showing as a broken link. I have the property type as "Media Picker",so they are selected within the "NewsArticle". What should I check? Did I refrence it incorrectly as
<img src="{featuredImage}" width="500"height="320"/>
Oh yes, I was assuming an "Upload field" for that property.
You'll just need to dig out the GetMedia() extension, I'd recommend using a separate template:
/Chriztian
Oh man - I did it again :-)
Here's that template again:
/Chriztian
That did the trick! Question though, $mediaNode variable that you pull using GetMedia(). What value is it? is it the image itself? or a property that holds all the node data for the image?
<img src="{$mediaNode/umbracoFile}" width="{$mediaNode/umbracoWidth}" height="{$mediaNode/umbracoHeight}" alt="{$mediaNode/@nodeName}" />
It's a chunk of XML, much like the content XML doc - looks something like this:
/Chriztian
is working on a reply...