Fórumok

Working with "selection list" fields in structure / template

thumbnail
Maese Theobald, módosítva 14 év-val korábban

Working with "selection list" fields in structure / template

Junior Member Bejegyzések: 64 Csatlakozás dátuma: 2009.09.08. Legújabb bejegyzések
Hello

Please could you help me in order to get the value of a "selection list" field of a web content structure?

We have some fields of this type in a structure but when we are going to retrieve them in the template, with the getData() method, we get the name of the option, not the value and we'd need to get the "friendly string" we use in the list, not the internal value.

Thanks
Fernanda Nery, módosítva 14 év-val korábban

RE: Working with "selection list" fields in structure / template

New Member Bejegyzés: 1 Csatlakozás dátuma: 2010.02.08. Legújabb bejegyzések
We have exactly the same doubt.
Have you found a solution yet?
Thanks.
thumbnail
Amos Fong, módosítva 14 év-val korábban

RE: Working with "selection list" fields in structure / template

Liferay Legend Bejegyzések: 2047 Csatlakozás dátuma: 2008.10.07. Legújabb bejegyzések
Hi,

Try .getOptions()

You can iterate through the list like so:

   
      Sample Multiple Selection List
      
        <b>
#foreach($selection in $sample-multi-selection-list.getOptions())
          $selection
          <br>
#end
        </b>
      
    


http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29
Francesco Cincotti, módosítva 13 év-val korábban

RE: Working with "selection list" fields in structure / template

New Member Bejegyzések: 5 Csatlakozás dátuma: 2010.10.01. Legújabb bejegyzések
Hi Amos,

getOptions() is OK for multi-selection lists, but I detected the same issue as Theobald:
when using the (single) selection lists, the getData() method extracts the name of the option instead of the value. I tried with getOptions(), getType(), looping on getChildren() and so on...but didnt't manage to get the value.

Many thanks
Francesco
thumbnail
Alexandre Bénard, módosítva 13 év-val korábban

RE: Working with "selection list" fields in structure / template

New Member Bejegyzések: 2 Csatlakozás dátuma: 2010.11.04. Legújabb bejegyzések
Hi,

I also confirm that getData() for a simple-selection-list return the name of the option and not the value (liferay version 6.0.5 CE).
It's seem related in the LPS-13737 issue.
I think the best will be to have access to key and value with a getKey() and getData() for exemple.

Alexandre
Michael Lauterbach, módosítva 10 év-val korábban

RE: Working with "selection list" fields in structure / template

New Member Bejegyzések: 4 Csatlakozás dátuma: 2013.04.02. Legújabb bejegyzések
Did anyone find a way to do this?
thumbnail
Luca Lauretta, módosítva 10 év-val korábban

RE: Working with "selection list" fields in structure / template

New Member Bejegyzések: 3 Csatlakozás dátuma: 2012.12.10. Legújabb bejegyzések
Amos Fong:
Hi,

Try .getOptions()

You can iterate through the list like so:

   
      Sample Multiple Selection List
      
        <b>
#foreach($selection in $sample-multi-selection-list.getOptions())
          $selection
          <br>
#end
        </b>
      
    


http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29


Your answer is about "multiple selection list" as it states in your example, and does not apply to the "selection list".
Could you help us with a solution for the "selection list" problem?
thumbnail
Tarun S. Kayasth, módosítva 8 év-val korábban

RE: Working with "selection list" fields in structure / template

Regular Member Bejegyzések: 162 Csatlakozás dátuma: 2007.06.08. Legújabb bejegyzések
LUCA ,

I am sure you got your answer by now.but here is the solution for others who are searching.

#foreach($selection in $selection-list.getSiblings())
  $selection.Data
          <br>
#end
thumbnail
Kiran Yalavali, módosítva 8 év-val korábban

RE: Working with "selection list" fields in structure / template

Regular Member Bejegyzések: 175 Csatlakozás dátuma: 2014.10.15. Legújabb bejegyzések
Hi tarun,

how to get the multiple text fields using single text with template
If am using repeatable="true" in structure pls give me any code with template

Thanks,
Kiran