Hi, I have a webpage built like this in umbraco 4.5.2:
Homepage
Subpage
Subsubpage
Subsubpage
Subpage
Subsubpage
Subsubpage
On top of each page is the company logotype which acts as a link to the homepage, so it's pretty standard stuff. I want the editor to be able to select the logotype in on place, and then have it set on all pages dynamically.
The best way I can figure out to do that would be to set the image as a property on the homepage and then use a xslt-macro to get the right image on each page.
Problem is I only started using umbraco this week, and I have almost no experience with xslt before this. I'm having trouble even getting images with xslt, and then when I try to combine it with finding the ancestor page it just turns into a horrible mess.
This is my latest attempt to get the image into a variable:
you can't use @template = 'startpage' as @template attribute is a number rather than text, so either use the number of the template, or even better, use the @level attribute as your home page (or 'startpage' document as you call it) will probably be the top level node in the content tree (well, the first node under 'Content')
If you are using the new XML schema (when you are running v4.5.2 I think you do) you can for sure use Dirks great answer, but you just have to make a small change to it. You need to replace this:
Getting image from logotype property on homepage
Hi, I have a webpage built like this in umbraco 4.5.2:
Homepage
Subpage
Subsubpage
Subsubpage
Subpage
Subsubpage
Subsubpage
On top of each page is the company logotype which acts as a link to the homepage, so it's pretty standard stuff.
I want the editor to be able to select the logotype in on place, and then have it set on all pages dynamically.
The best way I can figure out to do that would be to set the image as a property on the homepage and then use a xslt-macro to get the right image on each page.
Problem is I only started using umbraco this week, and I have almost no experience with xslt before this. I'm having trouble even getting images with xslt, and then when I try to combine it with finding the ancestor page it just turns into a horrible mess.
This is my latest attempt to get the image into a variable:
<xsl:variable name="LogotypeVariable" select="umbraco.library:GetMedia($currentPage/ancestor-or-self::node [@template='startpage']/logotype, 0)"/>
This is propably really simple once one knows how to do it, but I've been looking for an answer and found none.
And if anyone would know of a good tutorial on image handling in umbraco in general I would really appreciate it if they'd let me know.
/Danne Borell
you can't use @template = 'startpage' as @template attribute is a number rather than text, so either use the number of the template, or even better, use the @level attribute as your home page (or 'startpage' document as you call it) will probably be the top level node in the content tree (well, the first node under 'Content')
so, rewriting your xslt into:
should get you a reference to the media item, still will have to get the umbracoFile property of the LogotypeVariable.
Combining both into a single statement should result in:
and use that variable in an img tag
Hope this helps.
Regards,
/Dirk
Danne,
If you are using the new XML schema (when you are running v4.5.2 I think you do) you can for sure use Dirks great answer, but you just have to make a small change to it. You need to replace this:
with this:
So the variable will look like this:
/Kim A
Big thanks both of you, it worked like a charm :-)
/Danne
Great stuff! Thanks
is working on a reply...