Snippets

The Snippets feature is used to dynamically manage small pieces of content that can be displayed through out your store. Snippets can be versioned, each with multiple language variations and then scheduled to be automatically published and unpublished at various times in the future.

This article covers the basics.

Overview

Snippets are effectively small dynamic blocks of content that can be included almost anywhere in your stores front end templates. These could range from a Promotional offer and Contact Us details to JSON content. Aurora takes the content of a snippet and outputs it to the browser as is. How a snippet is displayed in your stores front end is determined by the location of the snippet tag in your stores templates. The content of a snippet can contain any text you wish. Some of the most common uses of snippets include:

  • HTML
  • StyleSheets (CSS)
  • JavaScript (JS)
  • Images
  • Videos
  • JSON Content

You can create and manage numerous Versions of the same snippet - with the additional option of Scheduling each version to appear at a specific time, replacing the previous. For example, this allows you to create a snippet with three different versions, covering Christmas Day, Boxing Day and New Years Day. Using the scheduler, you could schedule each version to automatically appear on the respective day, without having to do this manually.

Many snippets are already created for you and placed into templates throughout the front end, but you are also able to add new snippets and include them in templates yourself as you see fit.

👍

Constantly making changes to Snippets?

Don't forget you can use the Snippet Aurora API methods to get a list of all snippets currently set up in your store. You can also use the API to create new snippets, edit existing snippets and delete old snippets that are no longer required. You can even use the API to modify snippet content in the various languages set up in your store.

Managing Snippets

The Snippets section can be found by navigating to the Content > Snippets page. You'll be presented with a list of all the snippets that exist in your store. You can search through all snippets for a particular term using the Search Snippets field.

Snippets are managed like other items in Aurora.

ItemDescription
DateThe date that the snippet was created.
TitleThe snippets title. This is used to create the snippets tag, which is used to display the snippet in your front end templates.

The snippet tag is discussed in more detail below.
TypeThis tells Aurora whether it should attempt to decode the content of this snippet as JSON array data when rendering it to the Front-end Templates.
Internal DescriptionThis is your description for the snippet, and is used to differentiate one version from another.
ContentGives a preview of the content of the snippet.
Edit

Edit the respective snippet.
Delete

Delete the respective snippet.

Adding and Editing Snippets

New snippets can be added using the Add Snippet button. Similarly, existing snippets can be edited using the Edit Snippet icon.

Please note that new snippets can only be added in your stores default language. Once a new snippet has been saved, alternative language variations can then be added using the Switch Language drop down menu.

FieldDescription
Snippet Front End TagThe snippet front end tag is used to call the snippet for use in your stores front end templates. The tag is generated automatically by Aurora, and based on the snippets title. For this reason the title, and snippet tag need to be unique.

For more information on how snippet tags are used, see the Using Snippets section below.
TitleThe unique title of the snippet.
Internal DescriptionAn internal description can be specified for each version of a snippet.

Whilst the internal description doesn't have to be unique, we recommend that you give each version of a snippet a different description, as the description is useful to identify each version when they are being scheduled or compared.
TypeThis tells Aurora whether it should attempt to decode the content of this snippet as JSON array data when rendering it to the Front-end Templates:

- Text/HTML: This will output the content as text to be rendered.
- JSON: This will convert the content into its array data for use in the Front-end Templates.
PublishWhen this check box is selected, the snippet will be enabled for use in the front end. Otherwise, the snippet will not display.
Use in MerchandiserIf you would like to use a snippet within the Merchandising module, for example within a Sidebar , it can be enabled by selecting the Use in the Merchandiser? check box.
Enable SmartySnippets can contain Site Text and use Content Smarty Functions. Check the Enable Smarty? box to enable this feature for the respective snippet.
ContentEnter the content that the snippet is to represent.

This is what will be injected into your stores front end templates when the snippet is called. Content could include anything from a simple line of text, to a piece of HTML that embeds images and videos.
Show EditorYou can opt to manage the content of a snippet using the WYSIWYG editor by clicking on the Show Editor button.

This replaces the plain text area with a WYSIWYG editor. For more information on how and when to best use this editor, please read our WYSIWYG Tool support article.

Once shown, the WYSIWYG editor can be hidden using the Hide Editor button.
Choose LanguageThe content of a snippet can be managed on a per language basis. These language variations are also saved per snippet version. This allows you to control the content that appears on your store, at any time, for any language.

Use the language drop down menu to select the language you would like edit content for.
Delete SnippetDeletes the snippet that is currently being viewed.

Saving Snippets

The Publish checkbox is primarily used to determine if a snippet will show in the front end. If there are multiple versions of a snippet, the current version of a snippet will be shown. The current version is indicated on the Versions tab.

The current version may not necessarily be the latest version.

When saving a snippet, you have two options:

  • Save snippet as latest version and set as current.
    If you are currently editing the latest version of a snippet, this option will save any changes made to that version, and set it as the current version. If you are currently editing an older version of a snippet, this option will save any changes made as a new version, and set that version as current.
  • Save snippet as a new version.
    This will save any changes made as a new version, without changing which version of the snippet is current. 

Versioning, Scheduling and Comparing

Snippets take advantage of the Versioning, Scheduling and Comparison tools that Aurora has to offer. These allow you to create numerous versions of snippets, each of which can be viewed, edited and deleted. These versions can then be scheduled to appear at specific times, or compared against each other to find any key differences.

For more information on the benefits and use of these features, please see the respective support articles.

Using Snippets

👍

All published snippets can be displayed in a template by way of their snippet front-end tag. This tag can be found when editing a snippet by navigating to Content > Snippets > Edit. A snippets tag is based on its title, therefore a snippets title has to be unique.

You can display any snippet with this method, simply by appending the snippet tag to the end of the "$snippets." variable within the curly { } brackets.


🚧

Collect Plus has been removed from Aurora

The following remains as an example of how to use a snippet.

Text/HTML

To use the example Collect Plus Information snippet, simply enter the tag into any template, as per the example below:

<p>Some example template content.</p>

{$snippets.collect_plus_information}

<p>Some more example template content.</p>

JSON

Assuming that the Collect Plus Information has the following content and is set to be used as JSON:

{
  "description":"Collect Plus Description",
  "cost":"The Cost Information"
}

🚧

Remember to escape for Smarty

If you try to combine a JSON Snippet with the use of the Smarty Rendering Engine, please be sure to escape your non-Smarty-tag code with {literal} tags, e.g.

{literal}{{/literal}
  "description":"Collect Plus Description",
  "cost":"The Cost Information"
{literal}}{/literal}

You can use the Collect Plus Information snippet as a JSON array, simply enter the tag into any template, as per the example below:

<p>Some example template content.</p>

{$snippets.collect_plus_information.description} - {$snippets.collect_plus_information.cost}

<p>Some more example template content.</p>