1. Adding custom parameters
When adding or editing a product or a category there is an extra field where you can enter custom parameters for that product or category.
The field for entering custom parameters of products is located under the “Descriptions” tab in product-editing screen; the field for entering custom parameters of categories is available in the category-editing dialog.
Custom parameters are used for adding extra content to storefront pages. Examples of custom parameters:
color=red icon=new
In the above example parameters' names are color and icon, and their values are red and new.
Parameter name may consist only of Latin letters, digits, and underscore characters — without white spaces. The parameter name must be followed by an equal sign, which must be followed by the parameter name, which may contain an arbitrary text string, number, or HTML snippet.
Important note: Custom parameter name must not contain newline characters. Here is an incorrect example:
extra_description=<p> Extra product description:<br /> ... </p>
In this example the value of custom parameter extra_description contains only the opening <p> tag. Everything which is written in next lines will be recognized as other custom parameters if those other lines correspond to the above-mentioned rules; otherwise all additional lines will be ignored.
The correct method of adding a custom parameter is to write its value in one line:
extra_description=<p>Extra product description:<br />...</p>
2. Using custom parameters in design editor
Custom parameters can be used to add extra content to storefront pages. For example, if you would like to add an extra text block with product description to product-viewing pages, you may use the extra_description parameter suggested in the above example. To do so, find template product.html in the design editor and add the following code to the place where the extra description block should be displayed:
{$product.params.extra_description}
Custom parameters can also be used for applying custom appearance to individual product or category pages. For example you can use the following custom parameter:
style=color:#555; background-color: #eee;
Here is how this parameter can be used to change the style of some element (e.g., in the category.html template):
<div {if $category.params.style}style="$category.params.style"{/if}>...</div>
The values of custom parameters can be used in conditions of the form “if parameter value is equal to ... then display some information; otherwise display something else”. Below is an example of such a parameter:
promo=true
To do so, add the portion of code similar to that provided below to the desired template (e.g., product.html):
{if $product.params.promo} ...here is some promo information about this particular product... {else} ...here is information about all other products... {/if}
You can omit the {else} part if you do not need to display anything for all other products. In this case the above condition will look as follows:
{if $product.params.promo} ...here is some promo information about this particular product... {/if}
Custom parameters for other storefront elements
Extra pages
For pages which you can create in backend screen ”Storefront → Pages“ you can also specify custom parameters. Read more about using custom parameters with such pages in article ”Custom page parameters“.
Settlements
Custom parameters can also be specified in the settings of the online store settlement (i.e., storefront) available in the ”Routing“ section of the Site app. Values of such parameters can be accessed in design templates using the {$wa->globals()} method. For example, the value of parameter shop=books can be retrieved in any Smarty template as {$wa->globals('shop')}.
Use of custom settlement parameters may be useful for management of multiple storefronts with one copy of Shop-Script. Read more about setting up multiple storefronts →
0 comments
No comments yet.