• News
  • Developer information
  • Projects & contributions
  • Forum
  • Issue tracker
  • Open Funding
  • Security
  • User groups
  • Support
  • Store
  • Company

  • Path

    ez.no / exponential / documentation / development / libraries / ez template / functions / switch


    Switch

    These documentation pages are no longer maintained. Please visit the new documentation site.

    The switch function allows conditional control of output. For instance you can display a piece of HTML code depending on a template variable. The matching can be directly between to types or matching for an element in an array.

    The matching is done by creating one ore more case blocks inside the switch block. There must always be one default case present, a default case is created by inserting a case block without any parameters.

    The parameter to a case can either be match which determines the value to match against, or in which must contain an array. The match does a direct match, while the in looks for a match among the elements in the array. The in parameter behaves differently if the key parameter is used, which must be an identifier, it then assumes that the array sent to in has an array for each element and uses the key to match a key in the sub array.

    {let var=1}
    
     
    
    {* regular match *}
    
    {switch name=Sw1 match=$var}
    
     {case match=1}
    
     This one matches.
    
     {/case}
    
     
    
     {case match=2}
    
     This one does not match.
    
     {/case}
    
     
    
     {case}
    
     Not this one either.
    
     {/case}
    
    {/switch}
    
     
    
    {* in array matching *}
    
    {switch name=Sw2 match=$var}
    
     {case in=array(1,2)}
    
     This one matches.
    
     {/case}
    
     
    
     {case in=array(2,3)}
    
     This one does not match.
    
     {/case}
    
     
    
     {case}
    
     Not this one either.
    
     {/case}
    
    {/switch}
    
     
    
    {/let}

    Comments

    Contents

    Development

    Extensions
    Exponential datamodel
    Exponential tuning and stability
    Importing attribute data
    Kernel
    Libraries
        eZ xml
        eZ db
        eZ i18n
        eZ soap
        eZ template
           Basics
           Functions
              Function list
              Section
              Sequence
              Delimiter
              Switch
              Include
           Operators
        eZ webdav
    Scripting
    Standards
    System overview
    Test Suite
    Using Doxygen to create API documenta...


    Created

    07/07/2003
    3:17:46 pm
    by Bård Farstad

    Last updated

    12/07/2003
    1:39:56 pm
    by Björn Dieding@xrow.de

    Authors

    Bård Farstad
    Björn Dieding@xrow.de



    This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.