Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
The media picker property is called "mynd1". I created a partical view file.
I've got the following code:
@inherits umbraco.MacroEngines.DynamicNodeContext @if (Model != null) { var authorNode = Library.NodeById(Model.authorId); var articleImage = "css/images/dumy-article-small.gif"; <div class="article_header"> <div class="title">@Model.title</div> <div class="clear"></div> </div> <div class="second_header"> <div class="author_name"><b>Eftir</b>: @authorNode.fullName</div> <div class="category_diplaydate"> <b>Bólkur</b>: <a href="@Model.Parent.Url">@Model.Parent.Name</a><br /> <b>Dagfesting</b>: @Model.articleDate.ToString("dddd, dd.MM.yyyy HH:mm") <div class="print_icon"><a href="@umbraco.library.NiceUrl(2354)[email protected]" target="_blank"><img src="~/css/images/printer.png" alt="#" />Prenta</a></div> </div> </div> <div class="clear"></div> <br/> <div class="Manchet">@Model.manchet</div> <br/> <div> @if (item.HasValue("mynd1")) { var dynamicMediaItem = Umbraco.Media(item.mynd1); <a href="#"> <img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/></a> } </div> <div class="Breydtekstur">@Model.bodyText</div> <br/> }
But I'm getting an runtime error when I try to enter the page. Is anyone able to help me out?
I'm also using Umbraco 6.1.5
Hi Annfinn,
It looks like you have created a legacy "Scripting File" instead of a MVC "Partial View" or "Macro Partial View".
Your snippet should be something like this (make sure it's saved with the Views/Partials or Views/MacroPartials folder)
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var authorNode = Umbraco.Content(CurrentPage.authorId); var articleImage = "css/images/dumy-article-small.gif"; <div class="article_header"> <div class="title">@CurrentPage.title</div> <div class="clear"></div> </div> <div class="second_header"> <div class="author_name"><b>Eftir</b>: @authorNode.fullName</div> <div class="category_diplaydate"> <b>Bólkur</b>: <a href="@CurrentPage.Parent.Url">@CurrentPage.Parent.Name</a><br /> <b>Dagfesting</b>: @CurrentPage.articleDate.ToString("dddd, dd.MM.yyyy HH:mm") <div class="print_icon"><a href="@Umbraco.NiceUrl(2354)[email protected]" target="_blank"><img src="~/css/images/printer.png" alt="#" />Prenta</a></div> </div> </div> <div class="clear"></div> <br/> <div class="Manchet">@CurrentPage.manchet</div> <br/> <div> @{ var item = SOMETHING?????; if (item.HasValue("mynd1")) { var dynamicMediaItem = Umbraco.Media(item.mynd1); <a href="#"> <img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/></a> } } </div> <div class="Breydtekstur">@CurrentPage.bodyText</div> <br/> }
How are you calling your Partial View from your View?
Make sure you check the MVC documentation here.
Jeavon
Hello
thanks for taking time to answer my question. I'm in very early stages of programming. :(
The above code works, with out the
@{ var item = test; if (item.HasValue("mynd1")) { var dynamicMediaItem = Umbraco.Media(item.mynd1); <a href="#"> <img src="@dynamicMediaItem.umbracoFile" alt="@dynamicMediaItem.Name"/></a> } }
But as soon as I put in that codesnippet, I get runtime error.
I'm also using:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
instead of:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Is that an error on my behalf? It I don't use the PartialViewMacroPage, I also get an runtime error.
The Partial view is being called like this (hope it makes sense): CSHTML file -> Macro -> Template -> Document type.
The CSHTML file is located in the "Partial View Macro files" folder.
That's all fine, in not entirely sure what item is, but maybe try var item = CurrentPage; and see if thats what you're looking for?
item
var item = CurrentPage;
I found the issues. The issues was that I was using too many @'s :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Media Picker, image on page.
Hello,
The media picker property is called "mynd1". I created a partical view file.
I've got the following code:
But I'm getting an runtime error when I try to enter the page. Is anyone able to help me out?
I'm also using Umbraco 6.1.5
Hi Annfinn,
It looks like you have created a legacy "Scripting File" instead of a MVC "Partial View" or "Macro Partial View".
Your snippet should be something like this (make sure it's saved with the Views/Partials or Views/MacroPartials folder)
How are you calling your Partial View from your View?
Make sure you check the MVC documentation here.
Jeavon
Hello
thanks for taking time to answer my question. I'm in very early stages of programming. :(
The above code works, with out the
But as soon as I put in that codesnippet, I get runtime error.
I'm also using:
instead of:
Is that an error on my behalf? It I don't use the PartialViewMacroPage, I also get an runtime error.
The Partial view is being called like this (hope it makes sense): CSHTML file -> Macro -> Template -> Document type.
The CSHTML file is located in the "Partial View Macro files" folder.
That's all fine, in not entirely sure what
item
is, but maybe tryvar item = CurrentPage;
and see if thats what you're looking for?I found the issues. The issues was that I was using too many @'s :)
is working on a reply...