I'm looking for a way to inherit a site logo from the homepage of my site.
So I set the logo through the hompage and all the sub pages inherit the logo unless it's changed on one of the subpages. Anyone know a way of doing this.
The image works fine if I add it to the pages but with no image added it isn't inheriting.
It gives this error.
Server Error in '/' Application.
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Source Error:
Line 433:@{
Line 434: if (CurrentPage.HasValue("mainImage", true)){
Line 435: var dynamicMediaItem = Umbraco.Media(CurrentPage.mainImage);
Line 436:
Line 437: }
So if the current page have attached an image / logo then it will use this one for the page, If not, then it will go up in the content tree until it finds a page with the field "mainImage" and this field has a value.
Been awhile since I have done vb.net but this looks like it should be correct.
@If Model.Content.HasValue("mainImage", true) Then
Dim mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("mainImage",true))
<img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")"/>
End If
Inherit Site Logo
Hi
I'm looking for a way to inherit a site logo from the homepage of my site.
So I set the logo through the hompage and all the sub pages inherit the logo unless it's changed on one of the subpages. Anyone know a way of doing this.
Thanks
Hi David,
If you are using the media picker to pick the logo for the website something like this should do it,
If you are using dynamic Razor use the below code.
If you are using strongly typed Razor the code should look like this.
Remember to change the "mainImage" so it match your property alias for your media picker,
Hope this helps,
/Dennis
Thanks Dennis
I will give this a go.
Hello Dennis
This nearly works.
The image works fine if I add it to the pages but with no image added it isn't inheriting.
It gives this error.
Server Error in '/' Application. The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])' Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Media(params int[])' and 'Umbraco.Web.UmbracoHelper.Media(params string[])'
Source Error:
Line 433:@{
Line 434: if (CurrentPage.HasValue("mainImage", true)){
Line 435: var dynamicMediaItem = Umbraco.Media(CurrentPage.mainImage); Line 436: Line 437: }
Any ideas
thanks.
Hi David,
I made a little mistake. The code below should do what you are after.
So if the current page have attached an image / logo then it will use this one for the page, If not, then it will go up in the content tree until it finds a page with the field "mainImage" and this field has a value.
Hope this helps, and make sense.
/Dennis
Thanks Dennis
Works perfect, appreciate your help and quick response.
How can I do this in VB.Net?
Been awhile since I have done vb.net but this looks like it should be correct.
is working on a reply...