Back

custom field couple with program

  • Created: Nov 14, 2013
  • Author: shimanan
  • Title: computer
  • Company: none
  • Site: none

Description

This code will pull a list of content into a custom field and create a select box for each result.it couple with  programe  code  go to interner code,see  edit_field.jsp,this code  work  well.

Code

####prepare  work:

##new strutcture: departStruct
field          field type          label
name            text  (string)     english id
label           text (string)      label
sortorder       text (int)         sort order

##input  content:(example  china  city)
name           label            sortorder
wuhan       wuhan   city�__���                     0
beijing     beijing city��ъ��                     1
dalian      dalian  city�_���_                     2
shanghai    shanghai  city��_���                3
guangzhou    guangzhou  city�_���_          4



##below  is a new structure ,name  servitems(�ύ�_���܎�_) ,i  use  Custom Fields type,fieldVelocityVarName  is  departsel(�ύ�_��Ĭ�Ѭ)���it work  well.
##description  This code will pull a list of content into a custom field and create a select box for each result.



##set($_qk = "+structureName:Departstruct +(conhost:$host.identifier conhost:SYSTEM_HOST)")
#set($_qk = "+structureName:Departstruct ")
#set($cons = $dotcontent.pull(${_qk},0,"Departstruct.sortorder asc"))

 <select dojoType="dijit.form.FilteringSelect" autocomplete="true" id="${field.getVelocityVarName()}" name="${field.getFieldContentlet()}" ${field.isReadOnly()}?"readonly=\"\"":"">
	  <option value="" class="optionSelectField">please select...</option>
	  #foreach($con in $cons)
	    #set($name=$!{con.name})
	    #set($pairvalue=$!{con.label})
	    #set($selected = "")
	  #if ($UtilMethods.isSet($value))
	       #set($compareValue = ${value})
	  #elseif  ( $UtilMethods.isSet($defaultValue))
	        #set($compareValue = ${defaultValue})
	  #else   
	       #set($compareValue = "") 
	  #end
	     #if (  ($UtilMethods.isSet($compareValue)) &&($compareValue.equalsIgnoreCase(${name}))  )
                            #set($selected = "SELECTED")
         #end  
	    
       ##set($compareValue = ($UtilMethods.isSet($value) ? ${value} : ($UtilMethods.isSet($defaultValue) ? ${defaultValue} : "")))
     
         <option value="$!{name}" ${selected}> $!{pairvalue}</option>
   
	  #end
</select>