Im currently listing children from a specific ID, however, I want the the id to come from a folder, i've chosen from a content picker - My currently script looks like this:
@* LIST CHILDREN BY Chosen nodeId from a content picker ================================= *@
What is the value of bgImgFolder you are getting? It should be an int.
Also, it looks like you are trying to get all images from a media folder rather than a content folder? In that case you should use Model.MediaById(). In fact, in Umbraco 4.71 you really should use Library.NodeById() and Library.MediaById().
Seb, I've sometimes found Model.GetPropertyValue doesn't always work as expected with recursive properties - see http://umbraco.codeplex.com/workitem/30607. The way around I've found is to do the following:
List children by a nodeId from a content picker?
Hey...
Im currently listing children from a specific ID, however, I want the the id to come from a folder, i've chosen from a content picker - My currently script looks like this:
@*
LIST CHILDREN BY Chosen nodeId from a content picker
=================================
*@
@inherits umbraco.MacroEngines.DynamicNodeContext
<div class="rotator">
@foreach (var item in @Model.NodeById(1065).Children.Where("Visible"))
{
<figure data-img='@item.Media("backgroundImage", "umbracoFile")' class="show">
<figcaption>@item.sliderText</figcaption>
</figure>
}
</div>
The NodeById(1065) should be replaced with a id from the folder i've chosen with the content picker...
I've tried this, but this doens't work:
@inherits umbraco.MacroEngines.DynamicNodeContext
var bgImgFolder = @Model.AncestorOfSelf.backImages;
<div class="rotator">
@foreach (var item in @Model.NodeById(bgImgFolder).Children.Where("Visible"))
{
<figure data-img='@item.Media("backgroundImage", "umbracoFile")' class="show">
<figcaption>@item.sliderText</figcaption>
</figure>
}
</div>
What is the value of bgImgFolder you are getting? It should be an int.
Also, it looks like you are trying to get all images from a media folder rather than a content folder? In that case you should use Model.MediaById(). In fact, in Umbraco 4.71 you really should use Library.NodeById() and Library.MediaById().
The problem is that bgImgFolder is empty, so im not getting a value :(
Nope, it is items in a specific folder in the content the i want to loop...
So i need the Id of the folder i've chosen with the content picker at the template(item)
Looks like you're trying to the the bgImgFolder in a recursive way, this should work for you:
The "true" operator there says to look up in the tree recursively, it should find the first non-null, non-empty "backImages" property.
Seb, I've sometimes found Model.GetPropertyValue doesn't always work as expected with recursive properties - see http://umbraco.codeplex.com/workitem/30607. The way around I've found is to do the following:
That gets you a reference to the node, you can then access it's property as normal eg.
Thanks Dan, that is some horriblke code. Let's hope 4.7.1.1 comes out soon!
This works for me
@using System;
@using System.Web;
@using umbraco.NodeFactory;
@if (Model.Children.Where("Visible").Count() > 0)
{
<table class='subpages' cellpadding='0' cellspacing='0'>
<tr><th>In this section</th></tr>
<tr><td style='padding-left: 10px;'><ul class='sb_menu'>
@foreach (var subpage in Model.Children.Where("Visible"))
{
<li><a href="@subpage.Url">@subpage.Name</a></li>
}
</ul></td></tr>
</table>
}
is working on a reply...