Skip to content

System Variables#


In Miva Merchant, alongside local (l.) and global (g.) variables, there exists a third type known as System Variables, which are referenced using s.. System Variables are distinct in that they are initialized by the engine at the start of script execution, thereby relieving developers from the burden of initialization. These variables encompass CGI environment variables, HTTP header variables, and Miva-specific variables, enriching script functionality within the page template language.

Types of System Variables#

System Variables are categorized into two types: Dynamic and Static.

Dynamic Variables#

These are reset each time they are used in an expression. An example is time-related functions, which include both static and dynamic versions, offering flexibility depending on requirements.

Static Variables#

Set once at script initialization, static variables retain their value throughout script execution. Most System Variables fall under this category, providing stability and consistency during script execution.

Utilizing System Variables#

System Variables provide access to HTTP headers typically associated with incoming requests. These headers, such as http_referer, http_user_agent, and remote_addr, are automatically converted to System Variables. While System Variables cannot be directly output to the page, they can be utilized within conditional statements (if statements) or outputted using <mvt:eval> or <mvt:assign> tags.

Examples#

<mvt:eval expr="s.remote_addr" />
<mvt:assign name="g.referer" value="s.http_referer" />
&mvt:global:g.referer;
In this example, s.remote_addr retrieves the client’s IP address, while s.http_referer captures the referring page’s URL. Through <mvt:eval> and <mvt:assign>, developers can manipulate and output System Variables to suit specific requirements, facilitating robust script development and store customization.