From 919ebedd4e53192773f6b6c1e6ad84aa1784518e Mon Sep 17 00:00:00 2001 From: Daniele Procida Date: Wed, 16 Jan 2013 13:26:53 +0000 Subject: [PATCH 1/4] let's tame jQuery imports --- cms/admin/placeholderadmin.py | 2 +- cms/templates/admin/cms/page/plugin_change_form.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cms/admin/placeholderadmin.py b/cms/admin/placeholderadmin.py index 2a6a0227889..3e7f0b65918 100644 --- a/cms/admin/placeholderadmin.py +++ b/cms/admin/placeholderadmin.py @@ -30,7 +30,7 @@ class Media: 'css/plugin_editor.css', )] } - js = ['%sjs/jquery.min.js' % admin_static_url()] + [cms_static_url(path) for path in [ + js = [cms_static_url(path) for path in [ 'js/plugins/admincompat.js', 'js/csrf.js', 'js/libs/jquery.query.js', diff --git a/cms/templates/admin/cms/page/plugin_change_form.html b/cms/templates/admin/cms/page/plugin_change_form.html index 3b4d54195ed..a59257f3394 100644 --- a/cms/templates/admin/cms/page/plugin_change_form.html +++ b/cms/templates/admin/cms/page/plugin_change_form.html @@ -2,7 +2,7 @@ {% load i18n admin_modify cms_admin %} {% load url from future %} {% block extrahead %}{{ block.super }} - +{% block jquery.min.js %}{% endblock jquery.min.js %} From 7222147a891087b2d71e2a7b8f8e54888980e661 Mon Sep 17 00:00:00 2001 From: Daniele Procida Date: Wed, 16 Jan 2013 14:10:30 +0000 Subject: [PATCH 2/4] changed {% block %} name --- cms/templates/admin/cms/page/plugin_change_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/templates/admin/cms/page/plugin_change_form.html b/cms/templates/admin/cms/page/plugin_change_form.html index a59257f3394..d9f4807792d 100644 --- a/cms/templates/admin/cms/page/plugin_change_form.html +++ b/cms/templates/admin/cms/page/plugin_change_form.html @@ -2,7 +2,7 @@ {% load i18n admin_modify cms_admin %} {% load url from future %} {% block extrahead %}{{ block.super }} -{% block jquery.min.js %}{% endblock jquery.min.js %} +{% block jquery %}{% endblock jquery %} From be675eda3687c247c1cc7b1599b8b204b5288cc5 Mon Sep 17 00:00:00 2001 From: Daniele Procida Date: Thu, 17 Jan 2013 14:23:15 +0000 Subject: [PATCH 3/4] a note for the docs --- docs/extending_cms/custom_plugins.rst | 32 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/extending_cms/custom_plugins.rst b/docs/extending_cms/custom_plugins.rst index d540f1f9a2f..095ea2b5739 100644 --- a/docs/extending_cms/custom_plugins.rst +++ b/docs/extending_cms/custom_plugins.rst @@ -352,11 +352,35 @@ Since :class:`cms.plugin_base.CMSPluginBase` extends :class:`django.contrib.admin.options.ModelAdmin`, you can customize the form for your plugins just as you would customize your admin interfaces. -.. note:: +The template that the plugin editing mechanism uses is +``cms/templates/admin/cms/page/plugin_change_form.html``. You might need to +change this. - If you want to overwrite the form be sure to extend from - ``admin/cms/page/plugin_change_form.html`` to have a unified look across the - plugins and to have the preview functionality automatically installed. +If you want to customise this the best way to do it is: + +* create a template of your own that extends ``cms/templates/admin/cms/page/plugin_change_form.html`` to provide the functionality you require +* provide your :class:`cms.plugin_base.CMSPluginBase` subclass with a ``change_form_template`` attribute pointing at your new template + +Extending ``admin/cms/page/plugin_change_form.html`` ensures that you'll keep +a unified look and functionality across your plugins. + +There are various reasons *why* you might want to do this. For example, you +might have a snippet of JavaScript that needs to refer to a template +variable), which you'd likely place in ``{% block extrahead %}``, after a ``{{ +block.super }}`` to inherit the existing items that were in the parent +template. + + +Or: ``cms/templates/admin/cms/page/plugin_change_form.html`` extends Django's +own ``admin/base_site.html``, which loads a rather elderly version of jQuery, +and your plugin admin might require something newer. In this case, in your +custom ``change_form_template`` you could do something like:: + + {% block jquery %} + + {% endblock jquery %}`` + +to override the ``{% block jquery %}``. .. _custom-plugins-handling-media: From 6ab277ad68b0a99a5d2cb7caff10a1a378188535 Mon Sep 17 00:00:00 2001 From: Daniele Procida Date: Thu, 17 Jan 2013 14:28:18 +0000 Subject: [PATCH 4/4] docs note: sekizai is not for admin templates --- docs/extending_cms/custom_plugins.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/extending_cms/custom_plugins.rst b/docs/extending_cms/custom_plugins.rst index 095ea2b5739..26104e8a9c2 100644 --- a/docs/extending_cms/custom_plugins.rst +++ b/docs/extending_cms/custom_plugins.rst @@ -395,6 +395,9 @@ therefore those should be used to include the respective files. For more information about django-sekizai, please refer to the `django-sekizai documentation`_. +Note that sekizai *can't* help you with the *admin-side* plugin templates - +what follows is for your plugins' *output* templates. + Sekizai style -------------