Press Ctrl / CMD + C to copy this to your clipboard.
Copied to clipboard
Flag this post as spam?
This post will be reported to the moderators as potential spam to be looked at
Topic author was deleted
Nov 20, 2013 @ 20:30
How to display a logo on every page that is a for the user changable logo.
There are lots of topics about getmedia, but none of them seems to work for me. I cannot understand why I cannot complete such a simple task:
I have a very simple requirement: I want an image (logo) on every page, but not hard coded. It must me easily changeble by a user (not hard coded).
So, it looks obvious that I need a Masterlayout and make use of getmedia. None of the examples work for me. And I tried dozens of them. Most of the examples make use of an image that is part of a content type. But that can change on different pages, and I need the logo on every page and I only want to set is once.
Another alternative could be this: From Umbraco 4.11, there is a new control with name: umbraco:image. It is fairly simple to use, and should make it a bit easier to work with images. You use it like this Add this into your master template:
And with the umbraco:Image tag you can print images in the templates.
When I create a XSL file with your code I get this error when saving:
Error occured
System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType) at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
To rule out any special character, I've copied and pasted the code via Notepad.
The issue with the <umbraco:Image option is that I have a Master template and a sub template (I'm using the Business site starter kit). In order to get the logo on every page, I'll have to put the code in the mastertemplate. But the mastertemplate does not have a document type (or am I wrong?) I've alread set a property in the sub document type, and that works fine. The issue is that I have to enter a logo for every document type, so the logo is still not normalized.
And the way I normaly do it by adding a tab on the frontpage documenttype called site settings and on this tab I add a field called logo and the datatype is set to Media picker. After that then add the macro to the master template where the logo should appear.
Rember to change the alias of the field so it match your setup.
Topic author was deleted
How to display a logo on every page that is a for the user changable logo.
There are lots of topics about getmedia, but none of them seems to work for me. I cannot understand why I cannot complete such a simple task:
I have a very simple requirement: I want an image (logo) on every page, but not hard coded. It must me easily changeble by a user (not hard coded).
So, it looks obvious that I need a Masterlayout and make use of getmedia. None of the examples work for me. And I tried dozens of them. Most of the examples make use of an image that is part of a content type. But that can change on different pages, and I need the logo on every page and I only want to set is once.
Hi Richard and welcome to Our!.
You could try this code. I use to add a proppery for the frontpage called logo. Then I had a Master template where i add the XSLT macro on.
So i you add a field with the alias of logo on your documenttype for your frontpage with this code you should be good.
Another alternative could be this: From Umbraco 4.11, there is a new control with name: umbraco:image. It is fairly simple to use, and should make it a bit easier to work with images. You use it like this Add this into your master template:
And with the umbraco:Image tag you can print images in the templates.
It will output something like this e.g:
Hope this will help you print your logo.
/Dennis
Comment author was deleted
Thanks for your answer Dennis.
When I create a XSL file with your code I get this error when saving:
Error occured
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
To rule out any special character, I've copied and pasted the code via Notepad.
The issue with the <umbraco:Image option is that I have a Master template and a sub template (I'm using the Business site starter kit). In order to get the logo on every page, I'll have to put the code in the mastertemplate. But the mastertemplate does not have a document type (or am I wrong?) I've alread set a property in the sub document type, and that works fine. The issue is that I have to enter a logo for every document type, so the logo is still not normalized.
Hi Richard,
With this code you should be good.
<xsl:if test="$currentPage/logo !=''">
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/ancestor-or-self::*/logo, 0)"/>
<xsl:variable name="alt" select="umbraco.library:GetMedia($currentPage/ancestor-or-self::*/logo, 0) /nodeName"/>
<a href="/"><img src="{$media/umbracoFile}" alt="{$alt}"/></a>
</xsl:if>
And the way I normaly do it by adding a tab on the frontpage documenttype called site settings and on this tab I add a field called logo and the datatype is set to Media picker. After that then add the macro to the master template where the logo should appear.
Rember to change the alias of the field so it match your setup.
Hope this will work for you
/Dennis.
Comment author was deleted
Although I got the same error, your reply set me in the right direction.
I've made the macro and embedded it in the masterpage and it is rendering fine on all pages now.
Thanks Dennis.
Hi Richard,
I´m glad that I could help you and good to here that you got it to work,
/Dennis
is working on a reply...