@@ -624,17 +624,59 @@ You can nest CMS Plugins in themselves. There's a few things required to achieve
624
624
Plugin Attribute Reference
625
625
==========================
626
626
627
- A list of all attributes a plugin has and that can be overwritten:
627
+ A list of all attributes a plugin has and that can (or should) be overwritten:
628
+
629
+
630
+ admin_preview
631
+ -------------
632
+
633
+ Default: `False `
634
+
635
+ Should the plugin be previewed in admin when you click on the plugin or save it?
636
+
637
+
638
+
639
+ allow_children
640
+ --------------
641
+
642
+ Default: `False `
643
+
644
+ Can this plugin have child plugins? Or can other plugins be placed inside this plugin?
645
+ If set to True you are responsible to render the children in your plugin template.
646
+
647
+ Please use something like this or something similar::
648
+
649
+ {% load cms_tags %}
650
+ <div class="myplugin">
651
+ {{ instance.my_content }}
652
+ {% for plugin in instance.child_plugin_instances %}
653
+ {% render_plugin plugin %}
654
+ {% endfor %}
655
+ </div>
656
+
657
+
658
+ Be sure to access ``instance.child_plugin_instances `` to get all children.
659
+ They are pre-filled and ready to use. To finally render your child plugins use
660
+ the ``{% render_plugin %} `` templatetag.
661
+
662
+ See also: `child_classes `_, `parent_classes `_, `require_parent `_
663
+
664
+
665
+ cache
666
+ -----
667
+
668
+ Default: :setting: `CMS_PLUGIN_CACHE `
669
+
670
+ Is this plugin cacheable? If your plugin displays content based on the user or
671
+ request or other dynamic properties set this to False.
628
672
629
673
630
674
change_form_template
631
675
--------------------
632
676
633
- The template used to render the form when you edit the plugin.
677
+ Default: ` admin/cms/page/plugin_change_form.html `
634
678
635
- Default:
636
-
637
- `admin/cms/page/plugin_change_form.html `
679
+ The template used to render the form when you edit the plugin.
638
680
639
681
Example::
640
682
@@ -644,59 +686,44 @@ Example::
644
686
render_template = "cms/plugins/my_plugin.html"
645
687
change_form_template = "admin/cms/page/plugin_change_form.html"
646
688
647
- frontend_edit_template
648
- ----------------------
689
+ See also: `frontend_edit_template `_
649
690
650
- The template used for wrapping the plugin in frontend editing.
651
691
652
- Default:
653
-
654
- `cms/toolbar/placeholder_wrapper.html `
655
-
656
-
657
- admin_preview
692
+ child_classes
658
693
-------------
659
694
660
- Should the plugin be previewed in admin when you click on the plugin or save it?
661
-
662
- Default: False
663
-
695
+ Default: `None `
664
696
665
- render_template
666
- ---------------
697
+ A List of Plugin Class Names. If this is set, only plugins listed here can be added to this plugin.
667
698
668
- The path to the template used to render the template.
669
- Is required.
699
+ See also: `parent_classes `_
670
700
671
701
672
- render_plugin
673
- -------------
702
+ disable_child_plugin
703
+ --------------------
674
704
675
- Should the plugin be rendered at all, or doesn't it have any output?
705
+ Default: ` False `
676
706
677
- Default: True
707
+ Disables dragging of child plugins in structure mode.
678
708
679
- model
680
- -----
681
709
682
- The Model of the Plugin.
683
- Required.
710
+ frontend_edit_template
711
+ ----------------------
684
712
685
- text_enabled
686
- ------------
713
+ Default: `cms/toolbar/placeholder_wrapper.html `
687
714
688
- Default: False
689
- Can the plugin be inserted inside the text plugin?
715
+ The template used for wrapping the plugin in frontend editing.
690
716
691
- If this is enabled the following function need to be overwritten as well:
717
+ See also: ` change_form_template `_
692
718
693
- **icon_src() **
694
719
695
- Should return the path to an icon displayed in the text.
720
+ model
721
+ -----
696
722
697
- **icon_alt() **
723
+ This is required. The model of the Plugin. The defined model must extend
724
+ :class: CMSPlugin. If your plugin does not require any per-instance settings,
725
+ then this setting can be set to `CMSPlugin `.
698
726
699
- Should return the alt text for the icon.
700
727
701
728
page_only
702
729
---------
@@ -706,66 +733,87 @@ Default: False
706
733
Can this plugin only be attached to a placeholder that is attached to a page?
707
734
Set this to true if you always need a page for this plugin.
708
735
709
- allow_children
710
- --------------
736
+ See also: `child_classes `_, `parent_classes `_, `require_parent `_,
711
737
712
- Default: False
713
738
714
- Can this plugin have child plugins? Or can other plugins be placed inside this plugin?
715
- If set to True you are responsible to render the children in your plugin template.
716
-
717
- Please use something like this or something similar::
739
+ parent_classes
740
+ --------------
718
741
719
- {% load cms_tags %}
720
- <div class="myplugin">
721
- {{ instance.my_content }}
722
- {% for plugin in instance.child_plugin_instances %}
723
- {% render_plugin plugin %}
724
- {% endfor %}
725
- </div>
742
+ Default: None
726
743
744
+ A list of Plugin Class Names. If this is set, this plugin may only be added
745
+ to plugins listed here.
727
746
728
- Be sure to access ``instance.child_plugin_instances `` to get all children. They are pre-filled
729
- and ready to use. To finally render your child plugins use the ``{% render_plugin %} `` templatetag.
747
+ See also: `child_classes `_, `require_parent `_
730
748
731
749
732
- child_classes
750
+ render_plugin
733
751
-------------
734
752
735
- Default: None
736
- A List of Plugin Class Names. If this is set, only plugins listed here can be added to this plugin.
753
+ Default: True
737
754
755
+ Should the plugin be rendered at all, or doesn't it have any output? If
756
+ `render_plugin ` is true, then you must also define `render_template `
738
757
739
- parent_classes
740
- --------------
758
+ See also: `render_template `_
741
759
742
- Default: None
743
760
744
- A list of Plugin Class Names. If this is set, this plugin may only be added to plugins listed here.
761
+ render_template
762
+ _______________
763
+
764
+ The path to the template used to render the template. This is required if
765
+ `render_plugin ` is true.
766
+
767
+ See also: `render_plugin `_
745
768
746
769
747
770
require_parent
748
771
--------------
749
772
750
773
Default: False
751
774
752
- Is it required that this plugin is a child of another plugin? Or can it be added to any placeholder, even one attached to a page.
775
+ Is it required that this plugin is a child of another plugin? Or can it be
776
+ added to any placeholder, even one attached to a page.
753
777
778
+ See also: `child_classes `_, `parent_classes `_
754
779
755
- disable_child_plugin
756
- --------------------
780
+
781
+ text_enabled
782
+ ------------
757
783
758
784
Default: False
759
785
760
- Disables dragging of child plugins in structure mode.
786
+ Can the plugin be inserted inside the text plugin? If this is enabled then
787
+ `icon_src ` must be overriden.
788
+
789
+ See also: `icon_src `_, `icon_alt `_
790
+
791
+
792
+ translatable_content_excluded_fields
793
+ ------------------------------------
794
+
795
+ Default: [ ]
796
+
797
+ A list of plugin fields which will not be exported while using
798
+ :meth: `get_translatable_content `.
799
+
800
+ See also: `get_translatable_content `_, `set_translatable_content `_
801
+
802
+
803
+ Plugin Method Reference
804
+ =======================
805
+
806
+ A list of all methods a plugin has and that can (or should) be overwritten:
761
807
762
808
763
809
get_translatable_content
764
810
------------------------
765
811
766
- Get a dictionary of all content fields (field name / field value pairs) from the plugin.
812
+ Get a dictionary of all content fields (field name / field value pairs) from
813
+ the plugin.
767
814
768
- .. note :: This method and the one below should not be used on the plugin but rather on the plugin's instance.
815
+ .. note :: This method not be used on the plugin but rather on the plugin's
816
+ instance.
769
817
770
818
Example::
771
819
@@ -775,11 +823,59 @@ Example::
775
823
plugin.get_translatable_content()
776
824
# returns {'body': u'<p>I am text!</p>\n'}
777
825
826
+
827
+ See also: `translatable_content_excluded_fields `_, `set_translatable_content `_
828
+
829
+
830
+ icon_src
831
+ --------
832
+
833
+ By default, this returns an empty string, which, if left unoverridden would
834
+ result in no icon rendered at all, which would render the plugin uneditable
835
+ inside its parent text plugin.
836
+
837
+ This function accepts the `instance ` parameter and should return the path to
838
+ an icon to display in the text of the text plugin. Example::
839
+
840
+ def icon_src(self, instance):
841
+ return settings.STATIC_URL + "cms/img/icons/plugins/link.png"
842
+
843
+ See also: `text_enabled `_, `icon_alt `_
844
+
845
+
846
+ icon_alt
847
+ --------
848
+
849
+ Although it is optional, authors of `text_enabled ` plugins should consider
850
+ overriding this function as well.
851
+
852
+ This function accepts the `instance ` as a parameter and returns a string to be
853
+ used as the alt text for the plugin's icon which will appear as a tooltip in
854
+ most browsers. This is useful, because if the same plugin is used multiple
855
+ times within the same text plugin, they will typically all render with the
856
+ same icon rendering them visually identical to one another. This alt text and
857
+ related tooltip will help the operator distinguish one from the others.
858
+
859
+ By default `icon_alt() ` will return a string of the form: "[plugin type] -
860
+ [instance]", but can be modified to return anything you like.
861
+
862
+ The default implementation is as follows::
863
+
864
+ def icon_alt(self, instance):
865
+ return "%s - %s" % (force_unicode(self.name), force_unicode(instance))
866
+
867
+ See also: `text_enabled `_, `icon_src `_
868
+
869
+
778
870
set_translatable_content
779
871
------------------------
780
872
781
- Takes a dictionary of plugin fields (field name / field value pairs) and overwrites the plugin's fields. Returns True if all fields
782
- have been written successfully, and False otherwise.
873
+ Takes a dictionary of plugin fields (field name / field value pairs) and
874
+ overwrites the plugin's fields. Returns True if all fields have been written
875
+ successfully, and False otherwise.
876
+
877
+ .. note :: This method not be used on the plugin but rather on the plugin's
878
+ instance.
783
879
784
880
Example::
785
881
@@ -789,18 +885,4 @@ Example::
789
885
plugin.set_translatable_content({'body': u'<p>This is a different text!</p>\n'})
790
886
# returns True
791
887
792
- translatable_content_excluded_fields
793
- ------------------------------------
794
-
795
- Default: [ ]
796
-
797
- A list of plugin fields which will not be exported while using :meth: `get_translatable_content `
798
-
799
-
800
- cache
801
- -----
802
-
803
- Default: :setting: `CMS_PLUGIN_CACHE `
804
-
805
- Is this plugin cacheable? If your plugin displays content based on the user or request or other
806
- dynamic properties set this to False.
888
+ See also: `translatable_content_excluded_fields `_, `get_translatable_content `_
0 commit comments