#158

Product support

Get help in the plugin support forum.

Categories

  • Utility

One of the great features of RainLab Static Pages plugin is the Snippets feature. It allows the developer to hand over management of complex items, such as forms, maps, widgets, etc to the client. For more information on what a Snippet is, please see https://github.com/rainlab/pages-plugin#snippets.

This plugin simply extends the ability to re-use these snippets from any richeditor by providing an additional dropdown to the Froala Richeditor with a list of available snippets (supports partial and component based snippets). It also provides a twig filter to allow the parsing of implemented snippets. Example usage:

{{ content | parseSnippets }}

For documentation regarding creating snippets, please see https://github.com/rainlab/pages-plugin#snippets-created-from-partials

Features

  • Allows Snippets of code to be added from any RichEditor
  • Doesn't require any additional configuration
  • Provides Twig filter to easily parse Snippets
  • PHP and Twig sections work as expected inside Snippets
  • Works with component and partial based Snippets

Requirements

Other plugins to check out

  • Image Resizer - Provides Twig filter to resize images on the fly

The button will automatically appear in the Richeditor backend, no further customization is required here. You will only need to apply the Twig filter to the variables you would like to parse (see below).

Example usage on generic variable

{{ content | parseSnippets }}

Example usage for RainLab Pages Syntax Fields

Option 1 (offset to variable)

{variable type="richeditor" tab="Content" name="text" label="Text"}{/variable}
{{ text | parseSnippets }}

Option 2 (wrap in filter)

{% filter parseSnippets %}
    {richeditor tab="Content" name="text" label="Text"}{/richeditor}
{% endfilter %}

Example usage for Rainlab Pages Content Blocks

{% filter parseSnippets %}
    {% content 'company-details.htm' %}
{% endfilter %}

Example usage in fields.yaml

If you do not set toolbarButtons you will not need to add snippets to the list. Please see example below when customization is required.

html_content:
    type: richeditor
    toolbarButtons: bold|italic|snippets
    size: huge
1.0.3

Fixes error 'onInspectableGetOptions not found' on more complex snippets

Dec 07, 2016

1.0.2

Defines Rainlab.Pages as a plugin dependency - Thanks to Alexander Guth

Dec 07, 2016

1.0.1

First version of Richeditor Snippets

Nov 18, 2016