Search code examples
freemarkersitemapliferay-7liferay-7.3

Liferay 7: Is it possible to get an image for from a linked site to a sitemap automatically?


Liferay 7.3.2.
I'm using a sitemap to create link boxes that link to other pages in the website. Links and names and all else is basic stuff, but I have no idea, if and how I could get images for the boxes.

  • Asset publisher would've been my first choice, as I've done similar stuff before with them, but I can't find a way to add pages to the publisher, so I'm not sure if it's viable here. Of course, I could create an asset publisher that would ask for a name, image and a link, but this should be automatic to avoid extra hassle.
  • Sitemap allows for automation, if you just map the page correctly, but getting the image would still be a problem.
  • Navigation menu I haven't really put much thought into, as there will be many pages with link boxes and would be really hard to control. The image would be a problem as well.

The optimal solution would be to get the image from the page the link takes the user to, but if that's impossible, I wonder if there's a way to give webpage an image, that could be shown here.

Link boxes -example


Solution

  • Got it working with a bit of looking around! This can help with same kind of problems others might be facing, so I'll gladly answer this myself!

    • From Admin panel, go to Settings and Additional Fields

    • Select Page and add a field to it. After filling the details, you should be able to see this field in the page settings for every page.

    • Go to page settings and fill out your info. In my case, I created a text field, that will be used for image URLs.

    • Finally, in your Application Display Template, you can find the field by writing:
      ${entry.getExpandoBridge().getAttribute("Extra field")}, Extra Field being the name of your field. Remember to put conditional statements, if necessary!