Snippets

Table of contents

Introduction

To ease translating and changing text in templates Shopware uses snippets, which are called on by Smarty-variables in the template. So changes at the text don't consist of changes in the template.

Modifying snippets

Normal Mode

The modul to manage snippets is found under "Settings > Snippets". Opening the module displays every snippet available in all shops. To find the needed snippet, you can either use the navigation on the left side, filter by main- and subshop, empty snippets or search for their content.

After you found the correct snippet, you can alter it via the editing symbol. The choosen snippet will be highlighted and you are able to change it's content. After changing it, the update-button saves the snippet. For the changes to be visible in the storefront it is necessary to clear "Configuration + template-Cache".

Expert-Mode

Expert-Mode provides the option to delete single snippets. Also it is possible to change the Namespace ( the smarty variable). This should be used with caution, as texts in the storefront might not be displayed correct or at all after deleting a snippet or changing it's Namespace

Note:Never change the name or namespace of default snippets. This results in losing links to the template and possible template errors. Further possible errors could be crawling-errors by bots.

Import / Export of snippets

Importing & updating of snippets

You are provided with the possibility to import new snippets or to alter existing snippets via an import. This can be done using a CSV-file. The folowing fields are necessary:

FieldnameExplanation
namespaceName of the controller
nameName of the variable
value-de_DE-1German Content
value-en_GB-1English Content

Missing snippets will be created, existing will be updated.

Before manipulating snippets make sure to create a database backup!

Exporting snippets

Naturally it is possible to export existing snippets in various filetypes. Available for this operation are CSV (MS), CSV (delimiter) and SQL (Backup). The last one can be used to reset the snippets via SQL-statement.

Resetting of the SQL-file

If the snippets aren't displayed correctly anymore, it is possible to recreate the snippets as before the import. For this you open the SQL-file exported prior to the import and copy the SQL-statements out of the document. After this you need to open the database and insert the dump via the SQL-field. After these changes the old snippets should be there again.