I've been away from coding Razor and have forgotton a few things like how to refrence all the images within a folder. The images are stored in a node with doctype "CareerServicesPartnerFolder" and all the images are uploaded via the media picker and have the doctype "CareerServicesPartner". I have what I thought would work, if someone could look it over and help me out, that would be great!
Thanks Moran. I ended up making it harder than it needed to be. All I had to do was use this code (notice the image. "logo" is an alias attached to the images):
<div id="slider">
<ul class="bxslider">
@{
var root = Model.AncestorOrSelf("CareerServicesHome");
foreach(var partner in root.Descendants("CareerServicesPartner")) {
<li><a class="partner-box" target="_blank" href="@partner.partnerURL" title="@partner.linkTitle" >
@* for source of images using an uploader only need to use @yourCurrentNode.parameterAlias *@
<img src="@partner.logo" width="180px" title="@partner.linkTitle" alt="@partner.Name" />
</a></li>
};
}
</ul>
</div>
Load images from a node
I've been away from coding Razor and have forgotton a few things like how to refrence all the images within a folder. The images are stored in a node with doctype "CareerServicesPartnerFolder" and all the images are uploaded via the media picker and have the doctype "CareerServicesPartner". I have what I thought would work, if someone could look it over and help me out, that would be great!
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var root = Model.AncestorsOrSelf("CareerServicesHome"); foreach(var partner in root.Decendants("CareerServicesPartnerFolder")) { <div class="imageSlide"> <a class="partner-box" target="_blank" href="@partner.Url" title="@partner.Name" > <img src="partner.MediaById(Model.photo).umbracoFile" title="@partner.Name" alt="@partner.Name" /> /> </a> </div> }; }I've got it to load the @partner.Name, but not the images using this:
@{ var root = Model.AncestorOrSelf("CareerServicesHome"); foreach(var partner in root.Descendants("CareerServicesPartner")) { <div class="imageSlide"> <a class="partner-box" target="_blank" href="@partner.partnerUrl" title="@partner.linkTitle" > <img src="Model.MediaById(@Model.logo).umbracoFile" title="@partner.linkTitle" alt="@partner.Name" /> </a> </div> }; }I use this solution: I get the media Id and create a DynamicMedia object.
Thanks Moran. I ended up making it harder than it needed to be. All I had to do was use this code (notice the image. "logo" is an alias attached to the images):
<div id="slider"> <ul class="bxslider"> @{ var root = Model.AncestorOrSelf("CareerServicesHome"); foreach(var partner in root.Descendants("CareerServicesPartner")) { <li><a class="partner-box" target="_blank" href="@partner.partnerURL" title="@partner.linkTitle" > @* for source of images using an uploader only need to use @yourCurrentNode.parameterAlias *@ <img src="@partner.logo" width="180px" title="@partner.linkTitle" alt="@partner.Name" /> </a></li> }; } </ul> </div>is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.