Skip to content

repair-cafe/oc-richeditorsnippets-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

October Richeditor Snippets

Introduction

One of the great features of Rainlab 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.

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

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 %}

Note this method is useful if you are including a third party component that will output richeditors but you don't want to override its partial.

For example if you are using a richeditor with Rainlab.Blog, you may want to include the component as follow in your CMS page:

{% filter parseSnippets %}
    {% component 'blogPost' %}
{% 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

Pass extra parameters

If needed, you can pass extra parameters to your snippets from your theme like this:

{{ text | parseSnippets({context: 'foo'}) }}
{% filter parseSnippets({context: 'foo'}) %}
    {richeditor name="text" label="Text"}{/richeditor}
{% endfilter %}

You will then be able to access context as if it was a component property using $this->property('context').

Contributors

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 76.7%
  • JavaScript 23.3%