Snippets

Content placeholders in Joomla!

  • Last updated: 02-Oct-2018
  • Version: 6.4.3
  • Types: Component System plugin Editor button plugin
  • Joomla rating: 100%

Tutorial for Snippets

There is a Free and a Pro version of Snippets.
The parts in this tutorial that only concern the Pro version will be marked with: Pro only

Introduction

With Snippets you can include text snippets in your content. You can make reusable snippets (pieces of text/content) and include them into your content via a tag, like:

{snippet my-first-snippet}

If you edit the article (or module or wherever you put the tag), you will still see the tag. But on frontend view you will see the content of the snippet instead.

You can use this to insert much used content for instance. Then, if you change the content of the snippet, it changes everywhere you have used the tag.

The Snippets tag

The Snippets editor button will help you insert Snippets tag. You don't have to use this, you can also just type the tag directly into your content. The tags look like:

{snippet snippet-id}

So to place a snippet you have given the id 'copyright', you would have to place:

{snippet copyright}

Using dynamic snippets

You can pass along 'variables' with the tag which can be placed inside the snippet. This way you can use one snippet and it will generate different output, depending on what you pass along in the tag.

Then in the Snippet itself, you can put placeholders for variables with \1, \2, etc. So in the copyright example, your Snippet could look like:

©\2 - \1 - All rights reserved

You can pass along variables in the tag like:

{snippet copyright|My Company|2012}

This would output:

©2012 - My Company - All rights reserved

And with:

{snippet copyright|Another Company|2011}

You would get:

©2011 - Another Company - All rights reserved

Settings

Editor Button Options

Enable in frontend If enabled, it will also be available in the frontend.
Button Text This text will be shown in the Editor Button.

Other Settings

Snippet tag The word to be used in the tag.

Note: If you change this, all existing tags will not work anymore.
Tag Characters The surrounding characters of the tag syntax.

Note: If you change this, all existing tags will not work anymore.

Options: {...}, [...], {{...}}, [[...]], [:...:], [%...%]
Strip Surrounding Tags Select to always remove html tags (div, p, span) surrounding the plugin tag. If switched off, the plugin will try to remove tags that break the html structure (like p inside p tags).
Disable on Components Select in which frontend components NOT to enable the use of this extension.
Remove in Disabled Components If selected, the plugin syntax will get removed from the component. If not, the original plugins syntax will remain intact.
Place HTML comments By default HTML comments are placed around the output of this extension.

These comments can help you troubleshoot when you don't get the output you expect.

If you prefer to not have these comments in your HTML output, turn this option off.
Show Update Notification If selected, an update notification will be shown in the main component view when there is a new version for this extension.
Show Copyright If selected, extra copyright info will be displayed in the admin views. Regular Labs - extensions never show copyright info or backlinks on the frontend.

Installation

You can either install Snippets by using the core extension manager available in the Joomla! Administrator Control Panel, or by using the powerful Regular Labs Extension Manager.

Note: When updating Snippets, you do not need to uninstall it first. The package will update all the files automatically.

Keep in mind that when you update to a major new version (or uninstall first), you might lose some configuration settings.

Regular Labs Extension Manager

It is very easy to install/update any Regular Labs Extension using the Regular Labs Extension Manager.

Please see the Tutorial for the Regular Labs Extension Manager for more detailed information...

Joomla! Extension Manager

To install via the Joomla! Extension Manager, just follow these steps:

  1. Log into your Joomla administrator;
  2. In the menu, choose: Extensions >> Extensions;
  3. Choose the tab: Install from Web (or enable it if you haven't done so yet);
  4. Select the search field and enter Snippets and hit enter;
  5. Click on the Snippets listing;
  6. Click on Install;
  7. Click on Install to confirm.
Installer Web

Or if you need to install the Pro version or cannot install via the 'Install via Web' method for some reason:

  1. Download the extension install file (.zip);
  2. Log into your Joomla administrator;
  3. In the menu, choose: Extensions >> Extensions;
  4. Choose the tab: Upload Package File;
  5. Click on the Choose File button and select the extension zip;
  6. Click on Upload & Install.
Installer Upload

If you have problems installing Snippets, please try the manual installation process as described here: docs.joomla.org/Installing_an_extension