Several more Smarty plugins are available in the current Shopware version. This makes it even easier to deal with currencies, data (times), configurations, links and paths in the template. Below you will find all the information needed to use these plugins in your Smarty template.
The currency plugin allows you to control how prices are formatted and displayed in your shop. So you have the possibility to apply different predefined standard formats and to determine where, for example, the currency symbol will appear.
To activate the plugin, please use the following syntax:
Example: currency syntax
{* Syntax *}
{[Price]|currency:[FORMAT]:[CURRENCY POSITION}
{* Examplecall - Output: 49,95 EUR *}
{$sArticle.price|currency:use_shortname:right}
The following formats are available in the menu:
The following positions are available in the menu:
The config plugin grants you the ability to access and read the various features in the backend.
To do so, use the following syntax:
Example: config syntax
{* Syntax *}
{config name=[NAME OF PROPERTY]}
{* Examplecall "Disable vote" *}
{config name=VoteDisable}
The link plugin helps you to specify file paths, for example, when loading images or style sheets. We'll assume that you've installed your shop in a subdirectory shopware on your server (domain = http://www.meinshop.de) and would like to load a style sheet my_styles.css from the directory frontend/_resources/styles into your template my_template.
Without the plugin, the call looks like this:
Example: normal style sheet call
<link rel="stylesheet" media="screen, projection" href="http://www.meinshop.de/shopware/templates/my_template/frontend/_resources/styles/my_styles.css" />
By using the link plugin you only have to define the path relative to your own theme directory.
Example: Calling a style sheet via link plugin
<link rel="stylesheet" media="screen, projection" href="{link file='frontend/_resources/styles/my_styles.css'}" />
The syntax of the plugin looks like this:
{* Syntax *}
{link file="[PATH TO FILE]"}
With Shopware 5.2 the new media plugin was added.
In your Smarty templates you may use the {media path=...} expression to get the fully qualified URL.
Example: Calling an image via media plugin
<img src="{media path="media/image/my-fancy-image.png"}">
{media} evaluates the given path at template's compile time, so you cannot use runtime variables for its path argument (generally you will use a constant path as in the example above).
Shopware 5 Media Service Documentation
The url plugin gathers the URLS together from throughout the frontend and passes those specified on to the appropriate controller and action. Let's assume that you have a link that should connect to the wish list, then the call would look like this:
Example: example of a call to the wish list
{* A link to notes *}
<a href="{url controller='note'}" title="Show notes">
Show notes
</a>
The index action is always the default action. If you wish to call, for example, instant downloads in the account area, then the action must be passed on accordingly.
Example: example of a call to instant downloads
{* A link to instant downloads *}
<a href="{url controller='account' action='downloads'}" title="Open instant downloads">
Open instant downloads
</a>
You also have the option to pass on to the controller parameters. For this example, we'll extend the call to instant downloads with the parameter sParam with the value test.
Example: call to instant download with parameter
{* A link to instant downloads *}
<a href="{url controller='account' action='downloads' sParam='test'}" title="Open instant downloads with parameter">
Open instant downloads with parameter
</a>
The syntax of the url plugin is as follows:
Example: Syntax url plugin
{* Syntax *}
{url module='[FRONTEND/WIDGETS]' controller='[CONTROLLERNAME]' action='[ACTIONNAME]' [MORE PARAMETERS='PARAMETERVALUE']}
The plugin also automatically builds up the SEO links if the corresponding plugin is installed.
The date plugin is used to format date and time information. To this end, you have the ability to use a variety of formats. The syntax of the date plugin is as follows:
Example: date plugin syntax
{* Syntax *}
{[VALUE]|date:[FORMAT]:[TYPE]}
The plugin has the following format types, which are based on the Zend Framework:
Date:
Time:
Date/time:
Miscellaneous:
The following types can be defined for the plugin:
The plugin uses widgets to embed templates. Widgets are self-contained parts of the frontend, such as the shopping worlds.
{* Syntax *}
{action module=widgets controller=[CONTROLLERNAME] action=[ACTIONNAME] [[MORE PARAMETER]]}
{* Examplecall - Topseller *}
{action module=widgets controller=listing action=top_seller sCategory=$sCategoryContent.id}
In this case, an HTTP request is triggered internally within the system, resulting in widgets being completely dynamic elements which are not cached.
For further information read this blog: On action tags
To register custom smarty plugins please see register custom smarty plugins