|
|
 Rank: Enthusiast
Joined: 2/28/2008 Posts: 25
|
Hi all I am trying to implement the changeable headers as described here http://blogs.thesitedoctor.co.uk/tim/CommentView,guid,D812C9EB-91BF-4384-9840-3E840EE01FD2.aspx#fa8714c9-8206-4e18-92e4-587e81e4d6bd, and am running into a problem, that should be easy to resolve. The XSLT is listed below: 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" exclude-result-prefixes="msxml umbraco.library"> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:param name="currentPage"/> <xsl:template match="/"> <xsl:choose> <xsl:when test="$currentPage/ancestor-or-self::node [string(data[@alias='pageBanner'])!=''][1] /data[@alias='pageBanner'] != ''"> <xsl:value-of select="umbraco.library:GetMedia($currentPage/ancestor-or-self::node [data[@alias='pageBanner']!=''][1] /data[@alias='pageBanner'],'false')/data [@alias = 'umbracoFile']"/> </xsl:when> <xsl:otherwise> <!-- The URL of the default banner just incase the user removes the homepage banner (would be better as a parameter) --> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
What this does is display a URL to the image, and not display the actual image. I imagine you would need to encapsulate the code <xsl:value-of select="umbraco.library:GetMedia($currentPage/ancestor-or-self::node [data[@alias='pageBanner']!=''][1] /data[@alias='pageBanner'],'false')/data [@alias = 'umbracoFile']"/> into an image tag, but am a little unsure how to perform this easy task. Thanks for the help
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 671 Location: Belgium
|
Hey Andrew, You can do it like this: Code:
<img src={umbraco.library:GetMedia($currentPage/ancestor-or-self::node [data[@alias='pageBanner']!=''][1] /data[@alias='pageBanner'],'false')/data [@alias = 'umbracoFile']} />
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Enthusiast
Joined: 2/28/2008 Posts: 25
|
Excellent thanks for the help. I just add to add quotes around the {} - i.e. Code:<img src="{umbraco.library:GetMedia($currentPage/ancestor-or-self::node [data[@alias='pageBanner']!=''][1] /data[@alias='pageBanner'],'false')/data [@alias = 'umbracoFile']}" /> Thanks for the help
|
|
 Rank: Enthusiast
Joined: 2/28/2008 Posts: 25
|
oops
<img src="{umbraco.library:GetMedia($currentPage/ancestor-or-self::node [data[@alias='pageBanner']!=''][1] /data[@alias='pageBanner'],'false')/data [@alias = 'umbracoFile']}" />
|
|
Rank: Newbie
Joined: 3/18/2008 Posts: 3 Location: Germany
|
Thanks a lot for this tip. I am also new to umbraco and this helped me with my recent project. Umbraco and the peoples in this forum are very nice :-)
|
|
Rank: Newbie
Joined: 6/18/2008 Posts: 9 Location: Chile
|
i have a problem with this code when i use de default option... Code: <xsl:otherwise> media/default_image.jpg </xsl:otherwise>
it give me an error...."Error parsing XSLT file" what i'm doing wrong???? ..have exactly the same code without img tags
|
|
 Rank: Addict
Joined: 9/27/2007 Posts: 707 Location: Belgium
|
Hi, Replace Code:<xsl:otherwise> media/default_image.jpg </xsl:otherwise> with Code:<xsl:otherwise> <xsl:text>media/default_image.jpg</xslt:text> </xsl:otherwise> Regards, /Dirk
level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
|
Guest |