Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This tutorial shows how to use Velocity code on your catalog to conditionally show the items option based on the option type  This velocity code example is intended to be used within the Catalog templates:

 

Panel

Main Menu Configuration  Catalog 

Sample Code

Code Block
themeDJango
#foreach ($itemOption in $item.getOptions())
          
          #if ($itemOption.getType() == "single")
        
            <div class="entry">
            	<div class="entryleft">
            	<p>$itemOption.getLabel()</p>
                <input type="text" class="txt" name="OptionName$velocityCount" value=""/>
                </div>
              
                <div class="clear"></div>
            </div>
          #end
          
          #if ($itemOption.getType() == "dropdown")
          		<div class="entry">
            	 <div class="entryleft">
            	  <p>$itemOption.getLabel()</p>
                        <select name='OptionValue$velocityCount'>
        					#foreach($itemOptionValue in $itemOption.getDropDownValues())
          						<option>$itemOptionValue</option>
        					#end
      					</select>
                          </div>
                <div class="clear"></div>
            </div>
          
      		#end
          
           #end

...

Here we set a second conditional that we are looking for only item option with the following type. If this is true then we pull the options label, set the field for this option type. We then do the same for a different option type of "dropdown" and close the if statements

List of Option Types

NameDiscription
singleThis is for option with a type set of "Single line of free form text".
multilineThis is for option with a type set of "Multiple lines of free form text".
dropdownThis is for option with a type of "Drop down list of values".
file attachmentThis is for options with a type of "File attachment".
hiddenThis is for options with a type of "Hidden".
radioThis is for options with a type of "Radio button list of values".