Changeable headers using the media picker Options
andrew
Posted: Thursday, February 28, 2008 4:33:19 PM

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
tim
Posted: Thursday, February 28, 2008 4:41:51 PM

Rank: Addict

Joined: 2/19/2007
Posts: 634
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
andrew
Posted: Thursday, February 28, 2008 4:55:03 PM

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
andrew
Posted: Thursday, February 28, 2008 4:55:51 PM

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']}" />
SQueek
Posted: Saturday, April 19, 2008 9:47:23 AM
Rank: Newbie

Joined: 3/18/2008
Posts: 2
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 :-)
asdf-1
Posted: Friday, June 20, 2008 1:35:43 AM
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



Dirk
Posted: Friday, June 20, 2008 8:55:11 AM

Rank: Fanatic

Joined: 9/27/2007
Posts: 403
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
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.