My XML structure looks like this:
- links
- title
- image
- internal_link (Component Link)
- headline
- type
- section
I want to fetch the field headline
of internal_link
.
I am using the following code:
<div id="verticalNav">
@if (Model.Component.Fields.ContainsKey("links")
{
foreach (var lnk in Model.Component.Fields["links"].EmbeddedValues)
{
if (lnk.ContainsKey("internal_link"))
{
foreach (var intlnk in lnk["internal_link"].LinkedComponentValues)
{
if (intlnk.Fields.ContainsKey("headline"))
{
<p>intlnk.Fields["headline"].Value</p>
}
}
}
}
}
</div>
However, it's failing to check the condition intlnk.Fields.ContainsKey("headline")
. Yet field headline
has a value.
I increased the value of the linklevels
to 4, but still it is not working. Did I miss anything?