skip to navigation
skip to content

Not Logged In

emencia-cms-snippet 2.3.7

"cms.plugins.snippet" (from djangocms) cloned to extend it with some facilities

Latest Version: 2.4.1

This is a "cms.plugins.snippet" (from djangocms) cloned to extend it with some facilities.

Original code is from the original DjangoCMS plugin.

Changes from original code

This clone try to change as few orignal code as possible, actually the differences are :

  • Adding a template tag to directly use snippet fragments in the templates, not only from CMS pages;
  • Add usage of djangocodemirror for the HTML editor;

Requires

In the admin, the HTML content will be edited with the djangocodemirror editor.

Install

The only thing needed is to replace the cms.plugins.snippet in your DjangoCMS settings, like this :

INSTALLED_APPS = (
    'cms',
    # Plugins
    ...
    #'cms.plugins.snippet',
    'snippet', # the snippet plugin clone
    'djangocodemirror', # the editor
    ...
)

Then add :

CODEMIRROR_SETTINGS = {
    'cms_snippet': {
        'mode': {'name': "jinja2", 'htmlMode': True},
        'lineWrapping': True,
        'lineNumbers': True,
        'search_enabled': True,
        'embed_settings': True,
        'add_jquery': True,
        'lib_buttons_path': 'djangocodemirror/snippet_buttons.js',
    },
}

Because the code is cloned from the original plugin with just a few changes, all CMS stuff should work as with the original plugin, you should even add it in an existing install without loss in database and without any syncdb.

Usage

Template tags

Use the template tags in your templates :

{% load snippet_tags %}
{% snippet_fragment [Snippet ID or instance] %}

Like this :

{% load snippet_tags %}
{% snippet_fragment 42 %}

The required argument is for the Snippet ID or a Snippet instance if you want.

 
File Type Py Version Uploaded on Size
emencia-cms-snippet-2.3.7.tar.gz (md5) Source 2014-02-25 8KB
  • Downloads (All Versions):
  • 39 downloads in the last day
  • 136 downloads in the last week
  • 825 downloads in the last month