Request Vars Design Area

Last Updated: 03 Jan 2018

design_area_request_vars|asset|5.4.4.0

This design area allows you to access the contents of the GET, POST and REQUEST array in the design.

Bookmarks to the headings on this page:

  1. Set Variable
  2. Example

An example of a Request Vars design area is shown below.

<MySource_AREA id_name="get_vars" design_area="request_vars">
  <MySource_SET name="method" value="get" />
</MySource_AREA> 

The variable is then assigned to the background colour of a section, as shown below.

<style type="text/css" media="all">
  #breadcrumb {background-color: <MySource_PRINT id_name="get_vars" var="colour" />;}
</style> 

This can then be used in the URL to change the colour of the background. For example, the URL http://www.example.com?colour=aliceblue is entered. When the Home page is loaded the background colour of the asset lineage is alice blue (#F0F8FF), as shown in the figure below.

Setting the background colour of the asset lineage using a request variable
Setting the background colour of the asset lineage section using a request variable

Set Variable

The set variable that is available for the Request Vars design area is as follows:

  • method: set this value to either get, post or request to indicate which variable to access. By default, it is set to request.
    <MySource_AREA id_name="get_vars" design_area="request_vars">
    <MySource_SET name="method" value="get" />
    </MySource_AREA>

Example

In the following example, the Request Vars design area is used to access the GET variable array to determine if the user has logged in. If they have, it will redirect them to http://squiz.net. The code that is added to the parse file is shown below.

<head>
  <!-- Declared Vars -->
  <MySource_AREA id_name="login_redirect" design_area="declared_vars" print="no">
    <MySource_DECLARE name="url" value="http://squiz.net" type="text" description="The url to redirect the user to" />
  </MySource_AREA>

  <!-- Request Vars -->
<MySource_AREA id_name="get_vars" design_area="request_vars">
<MySource_SET name="method" value="get" />
</MySource_AREA>

  <!—Show If design area -->
  <MySource_AREA id_name="logon_box" design_area="show_if">
    <MySource_SET name="condition" value="logged_in" />
    <MySource_THEN>
      <script language="javascript">
        sq_action="<MySource_PRINT id_name="get_vars" var="SQ_ACTION" />";
        if ("login" == sq_action) {
          window.location="<MySource_PRINT id_name="login_redirect" var="url" />"
        }
      </script>
    </MySource_THEN>
  </MySource_AREA>
</head>