liferayvelocityliferay-themeliferay-velocity

Can't #foreach loop with my simple structure


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?


Solution

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

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