Of cource.. it was late when i wrote the question.
Im trying to get an image from the subpage.
It is a shop, and there are this structure:
Shop - Category -- Product
On the product site i have a Advanced Media Picker where i can choose 4 images. I want the first image, to be shown in the list of products, in the category.
@inherits umbraco.MacroEngines.DynamicNodeContext
@using DAMP = DAMP.PropertyEditorValueConverter.Model;
@{
var images = Model.Content.Children.GetPropertyValue<DAMP>("@childPage.image");
var firstImage = images.first;
}
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
@if (Model.Children.Where("Visible").Any())
{
<div id="isotopeContainer" class="isotope-container">
@* For each child page under the root node, where the property umbracoNaviHide is not True *@
@foreach (var childPage in Model.Children.Where("Visible"))
{
<div class="span3 isotope--target filter--suits" data-price="@childPage.price" data-popularity="1" data-size="m|l|xl" data-color="pink" data-brand="s-oliver">
<div class="product">
<div class="stamp green">@childPage.image</div>
<div class="product-img">
<div class="picture">
<img width="540" height="374" alt="@childPage.header" src="@firstImage.Url" />
<div class="img-overlay">
<a class="btn more btn-primary" href="@childPage.Url">Mere</a>
<a class="btn buy btn-danger" href="#">Læg i kurv</a>
</div>
</div>
</div>
<div class="main-titles no-margin">
<h4 class="title">@childPage.price</h4>
<h5 class="no-margin isotope--title"><a href="@childPage.Url">@childPage.Name</a></h5>
</div>
<div class="row-fluid hidden-line">
<div class="span6">
<a href="#" class="btn btn-small"><i class="icon-heart"></i></a>
<a href="#" class="btn btn-small"><i class="icon-exchange"></i></a>
</div>
<div class="span6 align-right">
<span class="icon-star stars-clr"></span>
<span class="icon-star"></span>
<span class="icon-star"></span>
<span class="icon-star"></span>
<span class="icon-star"></span>
</div>
</div>
</div>
</div>
}
</div>
}
Does this code works of do you get an error? You're using old and new Razor together. Model.Content probably even won't work. It's a bit hard to explain, but these topics might help:
Show image with DAMP
Hi
Umbraco v6.1.6
Digibiz Advanced Media Picker 2.7 (DAMP 2.7)
@using DAMP = DAMP.PropertyEditorValueConverter.Model; @{ var images = Model.Content.Children.GetPropertyValue<DAMP>("@childPage.image"); var firstImage = images.first; } <img width="540" height="374" alt="@childPage.header" src="@firstImage.Url" />When i test the DAMP with this
I get the id of the chosen images: 1114,1113,1112,1111
Any suggestions, what i´m doing wrong.
I have been looking to the "DAMP 2.0 Samples" :-)
René
I don't understand the following code completely. Can you show the complete Razor file and explain what you are trying to do?
Jeroen
Hi Jeroen
Of cource.. it was late when i wrote the question.
Im trying to get an image from the subpage.
It is a shop, and there are this structure:
Shop
- Category
-- Product
On the product site i have a Advanced Media Picker where i can choose 4 images. I want the first image, to be shown in the list of products, in the category.
@inherits umbraco.MacroEngines.DynamicNodeContext @using DAMP = DAMP.PropertyEditorValueConverter.Model; @{ var images = Model.Content.Children.GetPropertyValue<DAMP>("@childPage.image"); var firstImage = images.first; } @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@ @if (Model.Children.Where("Visible").Any()) { <div id="isotopeContainer" class="isotope-container"> @* For each child page under the root node, where the property umbracoNaviHide is not True *@ @foreach (var childPage in Model.Children.Where("Visible")) { <div class="span3 isotope--target filter--suits" data-price="@childPage.price" data-popularity="1" data-size="m|l|xl" data-color="pink" data-brand="s-oliver"> <div class="product"> <div class="stamp green">@childPage.image</div> <div class="product-img"> <div class="picture"> <img width="540" height="374" alt="@childPage.header" src="@firstImage.Url" /> <div class="img-overlay"> <a class="btn more btn-primary" href="@childPage.Url">Mere</a> <a class="btn buy btn-danger" href="#">Læg i kurv</a> </div> </div> </div> <div class="main-titles no-margin"> <h4 class="title">@childPage.price</h4> <h5 class="no-margin isotope--title"><a href="@childPage.Url">@childPage.Name</a></h5> </div> <div class="row-fluid hidden-line"> <div class="span6"> <a href="#" class="btn btn-small"><i class="icon-heart"></i></a> <a href="#" class="btn btn-small"><i class="icon-exchange"></i></a> </div> <div class="span6 align-right"> <span class="icon-star stars-clr"></span> <span class="icon-star"></span> <span class="icon-star"></span> <span class="icon-star"></span> <span class="icon-star"></span> </div> </div> </div> </div> } </div> }Hello,
Does this code works of do you get an error? You're using old and new Razor together. Model.Content probably even won't work. It's a bit hard to explain, but these topics might help:
http://our.umbraco.org/forum/developers/api-questions/46706-Razor-How-to-check-if-content-is-in-the-recycle-bin?p=0#comment167514
http://our.umbraco.org/projects/backoffice-extensions/digibiz-advanced-media-picker/digibiz-advanced-media-picker/39627-How-to-detect-if-no-items-have-been-picked#comment144735
http://our.umbraco.org/forum/developers/razor/44664-Confused-over-when-DynamicNodeList-is-returned?p=0#comment160691
So try using a Partial View Macro with the new syntax and see if that works: http://our.umbraco.org/documentation/Reference/Mvc/querying
Jeroen
The DAMP Gallery might help although it's a bit outdated.
Jeroen
Hi Joeren
No i got it working.
The previus Umbraco sites i have made, i have only used XSLT, but for this i desided to use razor.
Wow.. i got confused. There are different types for almoast each version of umbraco (Please correct me if im wrong!)
One goes from Umbraco version 4.7 > 4.10
and there are a new one from 4.10 > 6.0
And a new way of doing it in 6.0 >
It would be great in the wiki and documentation to clearly say witch version it is related to :-).
If this could help any one, here is my working code.
@using umbraco.MacroEngines @using umbraco.cms.businesslogic.media; @using umbraco.BusinessLogic; @inherits umbraco.MacroEngines.DynamicNodeContext @* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@ @if (Model.Children.Where("Visible").Any()) { <div id="isotopeContainer" class="isotope-container"> @* For each child page under the root node, where the property umbracoNaviHide is not True *@ @foreach (var childPage in Model.Children.Where("Visible")) { <div class="span3 isotope--target filter--suits" data-price="@childPage.price" data-popularity="1" data-size="m|l|xl" data-color="pink" data-brand="s-oliver"> <div class="product"> <div class="stamp green">Sale</div> <div class="product-img"> <div class="picture"> @if(childPage.HasValue("catImage")&& childPage.image.Count() > 0){ var image = @childPage.catImage.mediaItem[0].Image.umbracoFile; <img src="@image" alt="@childPage.header" width="540" height="374"/> }else if(childPage.catImage == ""){ <img src="/default.jpg" alt="autostyle missing image" width="540" height="374"/>} <div class="img-overlay"> <a class="btn more btn-primary" href="@childPage.Url">Mere</a> <a class="btn buy btn-danger" href="#">Læg i kurv</a> </div> </div> </div> <div class="main-titles no-margin"> <h4 class="title">@childPage.price</h4> <h5 class="no-margin isotope--title"><a href="@childPage.Url">@childPage.Name</a></h5> </div> <div class="row-fluid hidden-line"> <div class="span6"> <a href="#" class="btn btn-small"><i class="icon-heart"></i></a> <a href="#" class="btn btn-small"><i class="icon-exchange"></i></a> </div> <div class="span6 align-right"> <span class="icon-star stars-clr"></span> <span class="icon-star"></span> <span class="icon-star"></span> <span class="icon-star"></span> <span class="icon-star"></span> </div> </div> </div> </div> } </div> }
René
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.