I have a home page with 2 tabs
one of the tabs is Facts-And-Figures-Content tab
that has an Elias Facts-Figures-Items-Nested which is a nested Content from a Document Type without Template
I need to ask now how can I output these items on home page template
Accessing the nested content is a bit like accessing a normal property combined with access children of a node.
Assuming the following:
1) Your home node is of a document type called Home
2) Your nested content document types are called "FactsAndFigures"
3) The Facts-Figures-Items-Nested property has an alias of factsFiguresItemsNested
4) You are using Models Builder (which is normally on by default in the later versions of Umbraco)
There are two ways to go about this:
1)
@{
//This will give you an IEnumberable<IPublishedContent>
var factsAndFigures = Model.Content.FactsFiguresItemsNested;
foreach(var entry in factsAndFigures)
{
//You can access properties like any other IPublishedContent
<div>@entry.Name</div>
}
}
2) You can add a step of type-safe access by doing the following extra step:
@{
//This will give you an IEnumberable<IPublishedContent>
var factsAndFigures = Model.Content.FactsFiguresItemsNested;
foreach(var entry in factsAndFigures)
{
var typeSafeEntry = new FactsAndFigures(entry);
<div>@typeSafeEntry.Name</div>
}
}
Accessing the internal properties is exactly the same as accessing them as if they were on a normal IPublishedContent.
You can use GetPropertValue(), or if you go down the Models builder, type safe approach, they are just properties on the objects.
So for example:
@{
//This will give you an IEnumberable<IPublishedContent>
var factsAndFigures = Model.Content.FactsFiguresItemsNested;
foreach(var entry in factsAndFigures)
{
//You can access properties like any other IPublishedContent
<div>@entry.Name</div>
<div>@entry.GetPropertyValue("svgFactsIcon")</div>
}
}
output tabs alias nested Content
Hello I'm new to Umbraco
I have a home page with 2 tabs one of the tabs is Facts-And-Figures-Content tab that has an Elias Facts-Figures-Items-Nested which is a nested Content from a Document Type without Template I need to ask now how can I output these items on home page template
much Thanks !
Hi Rehamhabbas,
Accessing the nested content is a bit like accessing a normal property combined with access children of a node.
Assuming the following:
1) Your home node is of a document type called Home 2) Your nested content document types are called "FactsAndFigures" 3) The Facts-Figures-Items-Nested property has an alias of factsFiguresItemsNested 4) You are using Models Builder (which is normally on by default in the later versions of Umbraco)
There are two ways to go about this:
1)
2) You can add a step of type-safe access by doing the following extra step:
Hope that helps :-)
@nik
now how can I access the nested items inside
Thanks
Hi Rehamhabbas,
Accessing the internal properties is exactly the same as accessing them as if they were on a normal IPublishedContent.
You can use GetPropertValue(), or if you go down the Models builder, type safe approach, they are just properties on the objects.
So for example:
much appreciated your time and respond quickly I think I should go deeply with documentation and developers tutorial before starting my first project
Thanks a lot
I highly recommend Umbraco TV as an introduction to using Umbraco. It's got decent tutorials that you can follow along with. :-)
is working on a reply...