I wanted a button like feature(the picture kind of acts like a button) to repeat as long as nested content info is available. My nested content, called Portals consist of Link, Title and Picture. I would like to use the data in my nested content for my page.
It depends a little on your approach to templating, whether you are using Modelsbuilder etc but I think this is the gist of what you are asking
If the alias of your NestedContent item is called 'portals', then you can get a list of all the nested content items the editor has entered with something like the following:
@{
var portals = Model.Value<IEnumerable<IPublishedElement>>("portals");
var hasPortals = portals!=null && portals.any();
}
// and then you can display your data with:
@if (hasPortals){
// show somethng that only shows if there are buttons...
// loop through each portal nested content item
foreach (var portal in portals){
<h3 class="gdlr-core-event-item-title"><a href="#">@(portal.Value<string>("title"))</a></h3>
}
}
thank you Marc, it helps, but there are some parts that I'm stuck with, since I am very new with umbraco. I couldn't get the data from link and picture
@{
var portals = Model.Value<IEnumerable<IPublishedElement>>("portals");
var hasPortals = portals != null;
}
@if (hasPortals)
{
// show somethng that only shows if there are buttons...
// loop through each portal nested content item
foreach (var portal in portals)
{
<img [email protected]("picture")) width="700" height="450" alt="" />
<h3 class="gdlr-core-event-item-title"><a [email protected]("link"))>@(portal.Value<string>("title"))</a></h3>
}
}
You can take the link and picture value by doing the following
@{
@using umbraco.web.models; // to get the umbraco Link model
}
@if (hasPortals)
{
// show somethng that only shows if there are buttons...
// loop through each portal nested content item
foreach (var portal in portals)
{
<img [email protected]<IpublishedContent>("picture").Url()) width="700" height="450" alt="" />
<h3 class="gdlr-core-event-item-title"><a [email protected]<Link>("link").Url)>@(portal.Value<string>("title"))</a></h3>
}
}
How to use nested content
I wanted a button like feature(the picture kind of acts like a button) to repeat as long as nested content info is available. My nested content, called Portals consist of Link, Title and Picture. I would like to use the data in my nested content for my page.
This is what I'm aiming for
Anyone?
Hi strawberrylatte
It depends a little on your approach to templating, whether you are using Modelsbuilder etc but I think this is the gist of what you are asking
If the alias of your NestedContent item is called 'portals', then you can get a list of all the nested content items the editor has entered with something like the following:
if that helps? or have I misread...
regards
Marc
thank you Marc, it helps, but there are some parts that I'm stuck with, since I am very new with umbraco. I couldn't get the data from link and picture
Hi strawberrylatte,
You can take the link and picture value by doing the following
@{
@using umbraco.web.models; // to get the umbraco Link model
}
is working on a reply...