Pushing featured image into partial view macro file for article
Hi
I am trying to pull in a featured image for each article I write into a partial view macro file which will be visible on the front end.
I have created a partial view macro file which pulls in the content of children from a specific node as follows
In my article item document type, I have an upload property named "featuredImage"
I would like to pulls that into the macro so it displays along with the article so that on the front end I have the image along with the truncated and html stripped content.
Does anybody know an easy way to do this? (the featuredImage tag in the code is the bit that does not work yet and is part of my work in progress!)
the homelist is my macro partial where I amended the code.
I am not working in VS, just changing teh templates etc and making adjustments on the server, is there anything else i may have missed. I am quite new to this!
Pushing featured image into partial view macro file for article
Hi
I am trying to pull in a featured image for each article I write into a partial view macro file which will be visible on the front end.
I have created a partial view macro file which pulls in the content of children from a specific node as follows
In my article item document type, I have an upload property named "featuredImage"
I would like to pulls that into the macro so it displays along with the article so that on the front end I have the image along with the truncated and html stripped content.
Does anybody know an easy way to do this? (the featuredImage tag in the code is the bit that does not work yet and is part of my work in progress!)
Thanks
Hi
Can you please insert code as a code snippet, not an image.
Alex
I did try but it kept breaking, so here goes!
}
@page.PropertyAlias
@foreach (var child in page.Children) {
@child.Name
@Umbraco.StripHtml(@Umbraco.Truncate(@child.ArticleContents,140))
}
@{ var page = Umbraco.TypedContent(1065); }
Try this code, I moved the code from dynamic type to strongly typed:
Image rendering:
I got an error that it failed to load the partial view
Error loading Partial View script (file: ~/Views/MacroPartials/homelist.cshtml)
the homelist is my macro partial where I amended the code.
I am not working in VS, just changing teh templates etc and making adjustments on the server, is there anything else i may have missed. I am quite new to this!
What version of Umbraco are you using?
The latest version of 7. Downloaded and installed only yesterday :)
Try this code:
Hi
did you solve this issue?
Alex
is working on a reply...