docs.roxen.comView this page in a printer friendly mode
DocsRoxenWebServer 4.5Web Developer ManualIf Tags
Copyright  2012, Roxen Internet Software
Suggestions, comments & compliments

<if accept>
<if client>
<if clientvar>
<if config>
<if cookie>
<if date>
<if defined>
<if domain>
<if exists>
<if expr>
<if false>
<if group>
<if internal-exists>
<if ip>
<if kerberos-auth>
<if language>
<if match>
<if Match>
<if module>
<if pragma>
<if prestate>
<if referrer>
<if sizeof>
<if supports>
<if time>
<if true>
<if type-from-data>
<if type-from-filename>
<if user>
<if variable>
<if Variable>

<if type-from-data></if>

Provided by module: Tags: RXML 2 tags

Compares if the variable's data is known content type and tries to match that content type with the content type pattern.

This test is currently only capable of recognizing several common image formats. If the content format isn't recognized then the fallback content type in the Content Types module is tested against the pattern. That type is "application/octet-stream" by default. That also means that if the variable content is unknown and there is nothing to test the content type from, it will always return true:

   <set variable='var.fake-image' value='fakedata here'/>
   <if type-from-data='var.fake-image'>It is an image</if>
It is an image

While the correct way would be:

   <set variable='var.fake-image' value='fakedata here'/>
   <if type-from-data='var.fake-image is application/octet-stream'>
     Not known content type!
Not known content type!

This is an Eval plugin.

Related tags: <if#type-from-filename>, <cimg>, <guess-content-type>, <emit#dir>.

  <form method='post' enctype='multipart/form-data'>
    <input type='file' name='image' />
    <input type='submit' name='upload' />
  <if variable='form.image' and='' sizeof='form.image < 2048000'>
    File is less than 2MB
    <if type-from-data='form.image is image/*'>
      It's an image!
    <elseif type-from-filename='form.image is text/*'>
      It is a text file of some sort.
    <elseif type-from-filename='form.image is application/msword,application/pdf'>
      The image is a MS word- or pdf file.
    <elseif type-from-filename='form.image is application/octet-stream'>
      Invalid content type, type is unknown!
  <else>File larger than 2MB</else>