How to use “Cheat Sheet” variables in design editor

In design editor screens available in several Webasyst apps (e.g., Shop-Script 5, Site, Blog, Photos), there is a “Cheat Sheet” link at the bottom right. This link opens an informational block with a list of variables and methods, which can be used in the templates of the corresponding app.

Variables & methods

Variables and methods are convenient for fast adding of various data to website pages, when it is not convenient or even impossible to add them manually.

For example, variable {$wa_url} adds the relative URL of your installed Webasyst scripts to a Smarty template. If the framework is accessible at a URL of the form http://yourdomain.com/, then the relative URL is /. If the framework is installed at http://yourdomain.com/folder/, then the relative URL is /folder/. Relative URLs can be used for adding images to website pages, for example.

Certainly, you can specify relative URLs manually: / or /folder/; however, use of a variable in this case will help avoid taking the framework installation directory into account for easier website management. HTML code containing {$wa_url} variable may look as shown below:

<img src="{$wa_url}wa-data/public/site/images/logo.png">

Another example is method {$wa->locale()}. This method returns the name of the current user's locale. For example, for the English language it is “en_US”, an for Russian it will return “ru_RU”. Locale name can be used for displaying different content to different users; e.g,:

{if $wa->locale() == 'en_US'}
    ...content for English-speaking users...
{else}
    ...content for other users...
{/if}

“Cheat Sheet” tabs

In each app having a design editor there are several tabs in the “Cheat Sheet” area: app name tab (e.g., “Shop” or “Photos”), and “$wa” and “Smarty” tabs.

In the design editor available in the Site app there is no Cheat Sheet tab with its name because this app utilizes only system variables and methods described in other tabs and does not offer its own Smarty tools like other Webasyst apps.

App name tab contains the names and descriptions of variables and methods which are available only that specific app. For example, in the design editor available in Shop-Script 5 you can see methods used for obtaining information about products or product categories, in Photos app's Cheat Sheet there are variables containing information about albums and methods for obtaining photo lists by various criteria.

$wa” contains descriptions of system variables and methods offered by the Webasyst framework; e.g., variables containing the framework root URL and current settlement's URL, methods returning the full URL of the current website page, contents of the User-Agent string, and other variables and methods useful for design theme development and modification.

Smarty” briefly lists frequently used tools of the Smarty template engine which can be used in design theme templates; e.g., description of how to read or change values of template variables, how to access and manage data arrays, how to use conditions and cycles, etc. Please refer to the official documentation to find out more about using Smarty.

0 comments

    Add comment

    To add a comment please sign up or login