0

I'm having trouble looping through the social media links in my repeatable Authors structure.

Here is what the structure looks like:

enter image description here

The name field for the Authors section is authors and the name field for the social media links is social_media. The name field for each of the individual links are just their field names, facebook, twitter, etc. The Social Media field is a separator field if that makes any difference.

This is the code I'm trying to use to loop through the social media links:

#set($articleAuthors = $authors.getSiblings())


#foreach($author in $articleAuthors)

  <ul class="author-social-links">

    #foreach($link in $author.social_media)
      <li>$link.getData()</li>
    #end

  </ul>

#end  

This is what it results in:

enter image description here

It kind of works, but why is the $link.getData() being added to the ul as well?

Saad
  • 49,729
  • 21
  • 73
  • 112

1 Answers1

3

You should try adding Quiet Reference Notation like- $!{link.getData()}.

This will avoid getting this value printed when not actually populated.

Karma-yogi
  • 138
  • 11
  • Thanks. I'm not sure why this was happening as all the fields were populated. Using Quiet Reference Notation still made a blank `li` be created, so I just went with an `#if` statement to check if the field wasn't null before creating the `li`. – Saad Jul 09 '15 at 16:16
  • Well, actually that's exacly what you needed as pointed out by @PrakashKumar – Karma-yogi Jul 09 '15 at 17:45
  • Right, but why are there null values if all of the fields are being filled in? – Saad Jul 09 '15 at 17:58
  • I'm sure some of the fields are not being filled in because of some reason specific to your project. With the info you have shared, it looks difficult to figure that out. IMHO, you should ask a new question regarding this specifically tagged with liferay tags so that someone with appropriate expertise can take a call on that. – Karma-yogi Jul 09 '15 at 18:19