1

We are using liferay 6.1

On Public page we want to display web-content in one portlet, but it should not be only selected one.

we want to display it randomly on page refresh. Like on page refresh it should display different web content from group of web content.

Any hint ?

Thanks.

Hiral
  • 195
  • 1
  • 13

2 Answers2

2

Consider to use structures & templates: With structures you give some contents of an article - this might be alternative content, or just a description of a filter that you want to display.

A simple structure (that contains all of the content in just one article, not exactly what you ask for) just has repeatable HTML text fields. Edit all of them with the content you want to show alternating.

In your template you read an article with this content, generate a random number and only show the fragment from the content that the random number suggests.

Another way is to have a template that queries Liferay's API for several articles. Then you randomly select one of them and display it.

Templates can be written in Velocity, Freemarker or XSL. The nice thing is they're completely runtime-configurable.

Liferay Blogs, particularly those of James Falkner, have a few articles on how to work with the API from templates.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
1

You can customized the "Web Content Display" portlet with a hook. Add to config-page the "show randomized" checkbox, get the list of existing journal articles and choose random one of them.

Mark
  • 17,887
  • 13
  • 66
  • 93