5

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?

4
  • 1
    The subject of your question mentions 'nested embedded fields', but your code indicates that you have one level of embedded fields ("links"), and a component link field ("internal_link") inside of that. Can you confirm that this is correct? Maybe you can post the relevant part of the XML?
    – Quirijn
    Jul 15, 2013 at 14:03
  • 1
    Did you re-publish your components after changing the link level?
    – robrtc
    Jul 16, 2013 at 11:56
  • you are right robrtc,i missed to re-publish the component.But I cannot figure it out why we need to do that because components were published.
    – roop
    Jul 25, 2013 at 14:11
  • After any change in a Template or in the Component content, you need to publish these changes for them to appear on the delivery side. So you probably did make changes that hadn't been published, or maybe you tried publishing a Template which was still checked out (open in the Template Builder for example). Aug 12, 2013 at 12:43

1 Answer 1

4

The LinkLevels parameter in your TBB has to be set accordingly to include nested Component Links.

After any change in a Template or in the Component content, you will need to publish these changes for them to appear on the delivery side.

Since you mentioned you did make a change in the link levels, I'm assuming you haven't Published all Components using the Component Template you have changed the LinkLevels in, or maybe you tried Publishing a Template which was still checked out (open in the Template Builder for example). These are common causes for changes not to appear on the delivery side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.