掲示板
How to iterate array randomly in Velocity Template?
8年前 に Ronak Parekh によって更新されました。
How to iterate array randomly in Velocity Template?
Junior Member 投稿: 76 参加年月日: 15/04/06 最新の投稿
Hi Team,
I want to get value of repeatable structure field in velocity template randomly.
So I wanted to know that, how I can achieve random shuffling of an array in velocity template?
Please provide any help.
Thanks & Regards,
Ronak Parekh
I want to get value of repeatable structure field in velocity template randomly.
So I wanted to know that, how I can achieve random shuffling of an array in velocity template?
Please provide any help.
Thanks & Regards,
Ronak Parekh
8年前 に James Falkner によって更新されました。
RE: How to iterate array randomly in Velocity Template? (回答)
Liferay Legend 投稿: 1399 参加年月日: 10/09/17 最新の投稿
Use Collections.shuffle. Here's an example using a structure with a single repeatable textfield named name:
#set ($coll = $portal.getClass().forName('java.util.Collections'))
#set ($randomSiblings = $name.siblings)
#set ($V = $coll.shuffle($randomSiblings))
#foreach ($el in $randomSiblings)
<p>Random Sibling: $htmlUtil.escape($el.data)</p>
#end
8年前 に Ronak Parekh によって更新されました。
RE: How to iterate array randomly in Velocity Template?
Junior Member 投稿: 76 参加年月日: 15/04/06 最新の投稿
Hi James Falkner,
Thanks a lot. That solved my problem.
Thanks & Regards,
Ronak Parekh
Thanks a lot. That solved my problem.
Thanks & Regards,
Ronak Parekh