Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-32957

Not possible to extract names from Multi Selection List in Web Content Structures and Templates



      It does not appear to be currently possible to extract the names of items from a Multi Selection List in Web Content Structures and Templates.

      The example shown here: http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29#section-CMS+Template+(Velocity)-Iterating
      Currently only extracts the Data Types set in the XML structure and not the names. Arguably the Types are useless as they can't contain spaces or special characters and really don't lend themselves to being displayed on a page.

      Take this example:

      <?xml version="1.0"?>
      	<dynamic-element name="SupportedVersions" type="multi-list" index-type="keyword" repeatable="false">
      		<dynamic-element name="Liferay Portal 6.1 CE GA2 (6.1.1+)" type="CE61GA2" index-type="" repeatable="false"></dynamic-element>
      		<dynamic-element name="Liferay Portal 6.1 EE GA2 (6.1.20+)" type="EE61GA2" index-type="" repeatable="false"/>

      Using the example code in the template:

      <h2>Supported Versions: </h2>
          #if($SupportedVersions.getOptions().size() >0)
          #foreach($item in $SupportedVersions.getOptions())
              <li> $item </li>    

      Steps to reproduce it in master

      1. Create a web content structure with a select field
      2. Edit the field settings
      3. Set Name to SupportedVersions
      4. Edit the options and replace option1 with Liferay Portal 6.1 CE GA2, value1 with CE61GA2, option2 with Liferay Portal 6.1 EE GA2 and value2 with EE61GA2. Remove the option3-value3 line.
      5. Set Multiple to Yes
      6. Save changes
      7. Create a new template for the previously created structure.
      8. Select Velocity as template language
      9. Copy the template code above and save changes.
      10. Add a web content with the structure and template
      11. Mark all the values of the select field
      12. Save Changes.
      13. Display the web content in a web content display

      Current behavior
      All that's extracted and displayed on the page is:

      Expected Behavior
      However what should be displayed is:
      *Liferay Portal 6.1 CE GA2
      *Liferay Portal 6.1 EE GA2

      Really what's wanted is the list of human readable names - this is consistent with all the other data types available in the template which allow the user to extract the names.

      Sorting this out would greatly improve the usability of Web Content Structures and Templates where large lists of values are used. Currently the only workaround to this is to duplicate the lists in the template via a map.

      For further info see the following posts from users:


        1. example showing output .jpg
          example showing output .jpg
          14 kB
        2. Fixed.PNG
          20 kB
        3. master_LPS-32957_structure.txt
          1 kB
        4. master_LPS-32957_template.txt
          0.2 kB
        5. Reproduced.PNG
          23 kB
        6. sample_structure
          1 kB
        7. sample_vm
          0.7 kB
        8. Selection_003.png
          34 kB



            harry.chai Harry Chai
            scott.palmer@permeance.com.au Scott Palmer
            Participants of an Issue:
            Recent user:
            Brian Wulbern
            0 Vote for this issue
            5 Start watching this issue


              Days since last comment:
              4 years, 42 weeks ago


                Version Package
                7.0.0 Beta 3