Content
The Minibrowser allows the usage of variables. The var callback returns the corresponding value for the given variable.
There are two ways to initialize a variable:
- By adding it to the URL when calling the Minibrowser page. Example: http://link_to_the_minibrowser_code.xml#var:myvar=somevalue
By checking if the variable is empty and, if yes, refresh the page via mb_nop with the variable as parameter:
<If condition="$(empty:$(var:myvar))"> <fetch mil="1">phone://mb_nop#var:myvar=somevalue</fetch> </If>
Example 1: simple variable initialization
<?xml version="1.0" encoding="UTF-8"?> <SnomIPPhoneText id="text"> <If condition="$(empty:$(var:myvar))"> <fetch mil="1">phone://mb_nop#var:myvar=somevalue</fetch> </If> <Text>Variable is $(var:myvar)</Text> </SnomIPPhoneText>
Result when the variable value was added to the Minibrowser URL (URL called: http://10.110.16.61/xml/minibrowser/tests.xml#var:myvar=whatever)
Result when the variable value was not added to the Minibrowser URL (URL called: http://10.110.16.61/xml/minibrowser/tests.xml)
Example 2: Show the variable first_page before and after a value is assigned to it. The value of the callback will only last until the minibrowser is closed.
<?xml version="1.0" encoding="UTF-8"?> <SnomIPPhoneBatch> <SnomIPPhoneText id="page0"> <Title>page 0</Title> <SoftKeyItem> <Name>*</Name> <Url>http://link_to_this_example.xml#sub=*[@id="page1"]</Url> </SoftKeyItem> <Text> var:first_page: $(var:first_page) <br /> Press * to continue </Text> </SnomIPPhoneText> <SnomIPPhoneText id="page1"> <Title>page 1</Title> <SoftKeyItem> <Name>*</Name> <Url>http://link_to_this_example.xml#sub=*[@id="page2"]&var:first_page=$(urlencode:hello world)</Url> </SoftKeyItem> <Text> Pressing * will set variable 'var_first_page' to value 'hello_world' <br /> Press * to continue </Text> </SnomIPPhoneText> <SnomIPPhoneText id="page2"> <Title>page 2</Title> <SoftKeyItem> <Name>*</Name> <Url>http://link_to_this_example.xml#sub=*[@id="page0"]</Url> </SoftKeyItem> <Text> var:first_page: $(var:first_page) <br /> Press * to continue to Page0 </Text> </SnomIPPhoneText> </SnomIPPhoneBatch>
Result:
Further Information
Related articles