GeoPrisma logo

getValueFrom

For interoperability with other systems it is interesting to have the possibility to use dynamic values in the xml configuration file.

For example: One system is used to create a new feature with passes an attibute proprety in the url.

To allow this kind of interoperability it is possible to replace a fixed value in some xml nodes with a special <getValueFrom> tag that allows to get a value from any php variable table.

Use

<!-- fixed option -->
<option>value</option>

<!-- dynamique value -->
<option>
    <getValueFrom>$_REQUEST[param]</getValueFrom>
</option>
<option>
    <getValueFrom>$_POST[firstname] $_POST[lastname]</getValueFrom>
</option>
<option>
    <getValueFrom>$GLOBALS[lang]</getValueFrom>
</option>
<option>
    <getValueFrom>$SESSION[username]</getValueFrom>
</option>
<option>
    <getValueFrom>He is now" . date() . "</getValueFrom>
</option>

Implementation

The values set in getValueFrom tag are put into a string and are evaluated with the ‘eval’ php function.

Php code can then be used to return the desired value dynamically.

P.S : All widgets that use nodes loaded with getObjectFromNode are automatically compatible with getValueFrom (e.g. featurepanel_form fields)

Sample

  • Use ‘getValueFrom’ with the stylemap option of the map widget to colorize features with a attribute value equal to that passed along in the url.

    <stylemap>
        <renderers>
            <renderer>
                <renderintent>default</renderintent>
                <style>
                    <fillcolor>${getColor}</fillcolor>
                    <strokecolor>${getColor}</strokecolor>
                    <context>
                        <functions>
                            <fidegualfunction>
                                <name>getColor</name>
                                <egual>
                                    <getValueFrom>$_REQUEST[id]</getValueFrom>   <!-- <<<<<<<<<<<<< Here <<<<<<<<<<<<  -->
                                </egual>
                                <result>#FF00FF</result>
                                <defaultresult>#00FFFF</defaultresult>
                            </fidegualfunction>
                        </functions>
                    </context>
                </style>
            </renderer>
        </renderers>
    </stylemap>
    
  • Use ‘getValueFrom’ with the ‘editfeature_create’ and ‘featurepanel_form’ widgets to add features with an attribute value obtained from the url.

    <editfeature_create>
        <name>CreateDumpingSite</name>
        <options>
            <geometrytype>Polygon</geometrytype>
            <featurepanel>FeaturePanel1</featurepanel>
        </options>
    </editfeature_create>
    
    <featurepanel_form>
        <name>FeaturePanel1</name>
        <options>
            <inwindow>true</inwindow>
            <windowoffset>
                <left>100</left>
            </windowoffset>
            <windowoptions>
                <title>
                    <en_US>Dumping Site</en_US>
                    <fr_CA>Site de déversement</fr_CA>
                </title>
                <autoScroll>false</autoScroll>
            </windowoptions>
            <defaults>
                <width>100</width>
            </defaults>
            <fields>
                <field>
                    <name>dumpingid</name>
                    <xtype>displayfield</xtype>
                    <value>
                        <getValueFrom>$_REQUEST[id]</getValueFrom>  <!-- <<<<<<<<<<<<< Here <<<<<<<<<<<<  -->
                    </value>
                </field>
            </fields>
        </options>
    </featurepanel_form>
    

Table Of Contents

Previous topic

i18n (internationalization)

Next topic

API

This Page