Skip to content
This repository
Browse code

docs

git-svn-id: http://svn.django-cms.org/branches/django-cms2@297 92ec8317-e278-4cfe-9719-05471b91e6e2
  • Loading branch information...
commit 2b550e38dfd0fccdcd86eaa1cbaf65aeeedb5e97 1 parent ae014e2
authored March 30, 2009
17  AUTHORS
... ...
@@ -1,15 +1,14 @@
1 1
 Django CMS
2 2
 ==========
3  
-Patrick Lauber
4  
-Jason Zylks
  3
+* Patrick Lauber
  4
+* Jason Zylks
5 5
 
6 6
 
7 7
 Django Page CMS
8 8
 ===============
9  
-Batiste Bieler
10  
-Jannis Leidel
11  
-Antoni Aloy López
12  
-Benjamin Wohlwend
13  
-poweredbypenguins
14  
-homebrew79
15  
-
  9
+* Batiste Bieler
  10
+* Jannis Leidel
  11
+* Antoni Aloy López
  12
+* Benjamin Wohlwend
  13
+* poweredbypenguins
  14
+* homebrew79
88  INSTALL
... ...
@@ -1,88 +0,0 @@
1  
-Installation
2  
-============
3  
-
4  
-copy the cms and mptt folder into your project or pythonpath
5  
-
6  
-Apps
7  
-----
8  
-
9  
-add the following to your INSTALLED_APPS in your settings.py:
10  
-
11  
-INSTALLED_APPS = (
12  
- 	...
13  
-    'cms',
14  
-    'cms.plugins.text',
15  
-    'cms.plugins.picture',
16  
-    'mptt',
17  
-    ...
18  
-    
19  
-Django-cms 2.0 is compatible with django-reversion for versioning all the page content and its plugins.
20  
-
21  
-Middleware
22  
-----------
23  
-
24  
-add the following middlewares:
25  
-
26  
-MIDDLEWARE_CLASSES = (
27  
-    ...
28  
-    'cms.middleware.CurrentSiteMiddleware',
29  
-    'cms.middleware.CurrentPageMiddleware',
30  
-    'cms.middleware.MultilingualURLMiddleware',
31  
-    )
32  
-    
33  
-If your site is not multilingual you can leave out the MutilingualURLMiddleware
34  
-
35  
-Context Processors
36  
-------------------
37  
-add the following context processors if not already present:
38  
-
39  
-TEMPLATE_CONTEXT_PROCESSORS = (
40  
-    ...
41  
-    "django.core.context_processors.request",
42  
-    "cms.context_processors.media",
43  
-    )
44  
-
45  
-Templates
46  
----------
47  
-
48  
-Add some template names you use and that have some placeholder templatetags present
49  
-
50  
-CMS_TEMPLATES = (
51  
-    ('base.html', gettext('default')),
52  
-    ('2col.html', gettext('2 Column')),
53  
-    ('3col.html', gettext('3 Column')),
54  
-    ('extra.html', gettext('Some extra wired template')),
55  
-)
56  
-
57  
-For some template examples see the templates used in the example project
58  
-
59  
-a quick example:
60  
-
61  
-{% load cms_tags %}
62  
-
63  
-<div id="menu">{% show_menu 0 100 100 100 %}</div> 
64  
-<div id="breadcrumb">{% show_breadcrumb %}</div>
65  
-<div id="languagechooser">{% language_chooser %}</div>
66  
-<div id="content">{% placeholder "content" %}</div>
67  
-<div id="left_column">{% placeholder "left_column" %}</div>
68  
-    
69  
-i18n
70  
-----
71  
-
72  
-If your site is multilingual be sure to have the LANGUAGES present in your settings:
73  
-
74  
-LANGUAGES = (
75  
-    ('fr', gettext('French')),
76  
-    ('de', gettext('German')),
77  
-    ('en', gettext('English')),
78  
-)
79  
-
80  
-Other settings
81  
---------------
82  
-
83  
-For a list of all settings that can be overwritten in your settings.py have a look at cms/settings.py
84  
-
85  
-More information is available in the docs folder: cms/docs/
86  
-or have a look at the example project
87  
-
88  
-
21  README
... ...
@@ -1,21 +0,0 @@
1  
-Django CMS 2.0
2  
-==============
3  
-
4  
-A django app for managing hierarchical pages of content in multiple languages, on different sites.
5  
-
6  
-Django CMS handles the navigation rendering for you in multiple language with i18n slugs 
7  
-and the navigation can be extended by your own models.
8  
-
9  
-Pages are rendered with a template that have placeholders that get filled with plugins.
10  
-
11  
-Plugins included at the moment:
12  
-
13  
-Text
14  
-Picture
15  
-Flash
16  
-
17  
-Plugins are very easy to write and you can easily connect pages with your own models.
18  
-
19  
-For a feature comparison of all the cms apps available for django see: http://code.djangoproject.com/wiki/CMSAppsComparison
20  
-
21  
-visit django-cms.org or #django-cms on freenet for more info
28  README.md
Source Rendered
... ...
@@ -0,0 +1,28 @@
  1
+Django CMS 2.0
  2
+==============
  3
+
  4
+A django app for managing hierarchical pages of content in multiple languages, on different sites.
  5
+
  6
+Django CMS handles the navigation rendering for you in multiple language with i18n slugs 
  7
+and the navigation can be extended by your own models.
  8
+
  9
+Pages are rendered with a template that have placeholders that get filled with plugins.
  10
+
  11
+Plugins included at the moment:
  12
+
  13
+* Text
  14
+* Picture
  15
+* Flash
  16
+
  17
+many more are in the works.
  18
+
  19
+Plugins are very easy to write and you can easily write them on your own and connect them with your own models.
  20
+
  21
+For a feature comparison of all the cms apps available for django see: [CMSComparison](http://code.djangoproject.com/wiki/CMSAppsComparison)
  22
+
  23
+Install instructions you can find in the docs [here](http://github.com/digi604/django-cms-2.0/tree/master/cms/docs).
  24
+
  25
+visit [django-cms.org](http://www.django-cms.org/) or #django-cms on freenet for more info
  26
+
  27
+This is a fork of django-page-cms and the main differences are the plugin system and performance improvements.
  28
+
34  cms/docs/i18n.txt → cms/docs/i18n.md
Source Rendered
@@ -8,8 +8,8 @@ the multilingual url middleware adds a language prefix to every url.
8 8
 
9 9
 Example:
10 10
 
11  
-/de/account/login/
12  
-/fr/account/login/
  11
+	/de/account/login/
  12
+	/fr/account/login/
13 13
 
14 14
 It also adds this prefix automatically to every href and form tag.
15 15
 
@@ -22,29 +22,29 @@ The template in cms/language_chooser.html may be overwritten or your own templat
22 22
 
23 23
 Example:
24 24
 
25  
-{% load cms_tags %}
26  
-{% language_chooser "myapp/language_chooser.html" %}
  25
+	{% load cms_tags %}
  26
+	{% language_chooser "myapp/language_chooser.html" %}
27 27
 
28 28
 If the current url is not handled by the cms and you have some i18n slugs in the url you may use
29  
-the set_language_changer function in the view that handles the current url:
  29
+the set\_language\_changer function in the view that handles the current url:
30 30
 
31  
-in the models of the current object add a optional language parameter to the get_absolute_url function:
  31
+in the models of the current object add a optional language parameter to the 'get_absolute_url' function:
32 32
 
33  
-def get_absolute_url(self, language=None):
34  
-	reverse("product_view", args=[self.get_slug(language=language)])
  33
+	def get_absolute_url(self, language=None):
  34
+		reverse("product_view", args=[self.get_slug(language=language)])
35 35
 
36 36
 
37  
-In the view pass the set_language_changer the get_absolute_url function to the set_language_chooser function:
  37
+In the view pass the set_language_changer the get\_absolute\_url function to the set\_language\_chooser function:
38 38
 
39  
-from cms.utils import set_language_changer
  39
+	from cms.utils import set_language_changer
40 40
 	
41  
-def get_product(request, slug):
42  
-	item = get_object_or_404(Product, slug=slug, published=True)
43  
-    set_language_changer(request, item.get_absolute_url)
44  
-	...
  41
+	def get_product(request, slug):
  42
+		item = get_object_or_404(Product, slug=slug, published=True)
  43
+    	set_language_changer(request, item.get_absolute_url)
  44
+		...
45 45
 	
46 46
 This allows that the language chooser has an other url then the current one.
47  
-If the current url is not handled by the cms and no set_language_changer function is provided it will take the exact
  47
+If the current url is not handled by the cms and no set\_language\_changer function is provided it will take the exact
48 48
 same url as the current and only will change the language prefix.
49 49
 
50 50
 For the language chooser to work the MultilingualURLMiddleware must be installed.
@@ -52,11 +52,11 @@ For the language chooser to work the MultilingualURLMiddleware must be installed
52 52
 page_language_url
53 53
 -----------------
54 54
 
55  
-This tempalte_tag returns the url of the currentpage in an other language.
  55
+This template_tag returns the url of the current page in an other language.
56 56
 
57 57
 Example:
58 58
 
59  
-{% page_language_url "de" %}
  59
+	{% page_language_url "de" %}
60 60
 
61 61
 
62 62
 
90  cms/docs/installation.md
Source Rendered
... ...
@@ -0,0 +1,90 @@
  1
+Installation
  2
+============
  3
+
  4
+copy the cms and mptt folder into your project or pythonpath
  5
+
  6
+Apps
  7
+----
  8
+
  9
+add the following to your INSTALLED_APPS in your settings.py:
  10
+
  11
+	INSTALLED_APPS = (
  12
+ 		...
  13
+    	'cms',
  14
+    	'cms.plugins.text',
  15
+    	'cms.plugins.picture',
  16
+    	'mptt',
  17
+    	...
  18
+    
  19
+Django-cms 2.0 is compatible with django-reversion for versioning all the page content and its plugins.
  20
+
  21
+Middleware
  22
+----------
  23
+
  24
+add the following middlewares:
  25
+
  26
+	MIDDLEWARE_CLASSES = (
  27
+    	...
  28
+    	'cms.middleware.CurrentSiteMiddleware',
  29
+    	'cms.middleware.CurrentPageMiddleware',
  30
+    	'cms.middleware.MultilingualURLMiddleware',
  31
+    	...
  32
+    	)
  33
+    
  34
+If your site is not multilingual you can leave out the MutilingualURLMiddleware
  35
+
  36
+Context Processors
  37
+------------------
  38
+add the following context processors if not already present:
  39
+
  40
+	TEMPLATE_CONTEXT_PROCESSORS = (
  41
+    	...
  42
+    	"django.core.context_processors.request",
  43
+    	"cms.context_processors.media",
  44
+    	...
  45
+    	)
  46
+
  47
+Templates
  48
+---------
  49
+
  50
+Add some template names you use and that have some placeholder templatetags present to your settings.py
  51
+
  52
+	CMS_TEMPLATES = (
  53
+    	('base.html', gettext('default')),
  54
+    	('2col.html', gettext('2 Column')),
  55
+    	('3col.html', gettext('3 Column')),
  56
+    	('extra.html', gettext('Some extra wired template')),
  57
+	)
  58
+
  59
+For some template examples see the templates used in the example project
  60
+
  61
+a quick example:
  62
+
  63
+	{% load cms_tags %}
  64
+
  65
+	<div id="menu">{% show_menu 0 100 100 100 %}</div> 
  66
+	<div id="breadcrumb">{% show_breadcrumb %}</div>
  67
+	<div id="languagechooser">{% language_chooser %}</div>
  68
+	<div id="content">{% placeholder "content" %}</div>
  69
+	<div id="left_column">{% placeholder "left_column" %}</div>
  70
+    
  71
+i18n
  72
+----
  73
+
  74
+If your site is multilingual be sure to have the LANGUAGES present in your settings:
  75
+
  76
+	LANGUAGES = (
  77
+    	('fr', gettext('French')),
  78
+    	('de', gettext('German')),
  79
+    	('en', gettext('English')),
  80
+	)
  81
+
  82
+Other settings
  83
+--------------
  84
+
  85
+For a list of all settings that can be overwritten in your settings.py have a look at cms/settings.py
  86
+
  87
+More information is available in the docs folder: cms/docs/
  88
+or have a look at the example project
  89
+
  90
+
155  cms/docs/navigation.txt → cms/docs/navigation.md
Source Rendered
@@ -11,16 +11,16 @@ You can overwrite the appearance and the html if you add a cms/menu.html templat
11 11
 show_menu takes 4 parameters:
12 12
 from what level of the navigation to which level should the navigation be rendered?
13 13
 
14  
-start level (default=0)
15  
-end_level (default=100)
  14
+**start_level** (default=0)  
  15
+**end_level** (default=100)
16 16
 
17 17
 if you have a home as a root node and don't want to display home you can render the navigation only after level 1
18 18
 
19  
-extra_inactive (default=0)
  19
+**extra_inactive** (default=0)
20 20
 
21 21
 if a node is not a direct ancestor or descendant of the current active node how many levels deep should the navigation be displayed?
22 22
 
23  
-extra_active (default=100)
  23
+**extra_active** (default=100)
24 24
 
25 25
 if a node is the current active, how many levels deep should its descendants be displayed?
26 26
 
@@ -28,29 +28,32 @@ Some Examples:
28 28
 
29 29
 Complete navigation (as a nested list)
30 30
 
31  
-{% load cache cms_tags %}
32  
-<ul>
33  
-	{% show_menu 0 100 100 100 %}
34  
-</ul>
  31
+	{% load cache cms_tags %}
  32
+	<ul>
  33
+		{% show_menu 0 100 100 100 %}
  34
+	</ul>
35 35
 
36 36
 Navigation with active tree(as a nested list)
37  
-<ul>
38  
-	{% show_menu 0 100 0 100 %}
39  
-</ul>
  37
+
  38
+	<ul>
  39
+		{% show_menu 0 100 0 100 %}
  40
+	</ul>
40 41
 
41 42
 Navigation with only 1 active extra level
42  
-<ul>
43  
-	{% show_menu 0 100 0 1 %}
44  
-</ul>
  43
+
  44
+	<ul>
  45
+		{% show_menu 0 100 0 1 %}
  46
+	</ul>
45 47
 
46 48
 Level 1 navigation (as a nested list)
47  
-<ul>
48  
-	{% show_menu 1 %}
49  
-</ul>
  49
+
  50
+	<ul>
  51
+		{% show_menu 1 %}
  52
+	</ul>
50 53
 
51 54
 Navigation with own template:
52 55
 
53  
-{% show_menu 0 100 100 100 "myapp/menu.html" %}
  56
+	{% show_menu 0 100 100 100 "myapp/menu.html" %}
54 57
 
55 58
 show_sub_menu
56 59
 -------------
@@ -59,15 +62,15 @@ Display the sub menu of the current page (as a nested list)
59 62
 Takes one argument: how many levels deep should the submenu be displayed?
60 63
 The template can be found at cms/sub_menu.html
61 64
 
62  
-<ul>
63  
-    {% show_sub_menu 1 %}
64  
-</ul>
  65
+	<ul>
  66
+    	{% show_sub_menu 1 %}
  67
+	</ul>
65 68
 
66 69
 with your own template:
67 70
 
68  
-<ul>
69  
-    {% show_sub_menu 1 "myapp/submenu.html" %}
70  
-</ul>
  71
+	<ul>
  72
+    	{% show_sub_menu 1 "myapp/submenu.html" %}
  73
+	</ul>
71 74
 
72 75
 show_breadcrump
73 76
 ---------------
@@ -75,11 +78,11 @@ show_breadcrump
75 78
 Show the breadcrumb navigation of the current page
76 79
 The tamplate for the html can be found at cms/breadcrumb.html
77 80
 
78  
-{% show_breadcrumb %}
  81
+	{% show_breadcrumb %}
79 82
 
80 83
 with your own template:
81 84
 
82  
-{% show_breadcrumb "myapp/breadcrumb.html" %}
  85
+	{% show_breadcrumb "myapp/breadcrumb.html" %}
83 86
 
84 87
 If the current url is not handled by the cms or i a navigation extender you may need to provide your own breadcrump via the template.
85 88
 This is mostly needed for pages like login, logout and 3th party apps.
@@ -95,54 +98,54 @@ For example you have a shop with categories and want these categories to be disp
95 98
 
96 99
 Add the following to your settings file:
97 100
 
98  
-CMS_NAVIGATION_EXTENDERS = (('myapp.utils.get_nodes', gettext('Shop Categories')),)
  101
+	CMS_NAVIGATION_EXTENDERS = (('myapp.utils.get_nodes', gettext('Shop Categories')),)
99 102
 
100 103
 Now you are able to link a Navigation Extender to a page in the Advanced Tab of the Page Settings.
101 104
 
102 105
 An example of an extender function in a utils.py in myapp:
103 106
 
104  
-from categories.models import Category
105  
-
106  
-def get_nodes(request):
107  
-    cats = list(Category.objects.all())
108  
-    res = []
109  
-    all_cats = cats[:]
110  
-    childs = []
111  
-    for cat in cats:
112  
-        if cat.parent_id:
113  
-            childs.append(cat)
114  
-        else:
115  
-            res.append(cat)
116  
-    for cat in all_cats:
117  
-        cat.childrens = []
118  
-        for child in childs:
119  
-            if child.parent_id == cat.pk:
120  
-                cat.childrens.append(child)
121  
-    return res
  107
+	from categories.models import Category
  108
+
  109
+	def get_nodes(request):
  110
+    	cats = list(Category.objects.all())
  111
+    	res = []
  112
+    	all_cats = cats[:]
  113
+    	childs = []
  114
+    	for cat in cats:
  115
+        	if cat.parent_id:
  116
+            	childs.append(cat)
  117
+        	else:
  118
+            	res.append(cat)
  119
+    	for cat in all_cats:
  120
+        	cat.childrens = []
  121
+        	for child in childs:
  122
+            	if child.parent_id == cat.pk:
  123
+                	cat.childrens.append(child)
  124
+    	return res
122 125
     
123 126
 The model would look something like this:
124 127
 
125  
-from django.db import models
126  
-from django.core.urlresolvers import reverse
127  
-import mptt
  128
+	from django.db import models
  129
+	from django.core.urlresolvers import reverse
  130
+	import mptt
128 131
 
129  
-class Category(models.Model):
130  
-    parent = models.ForeignKey('self', blank=True, null=True)
131  
-    name = models.CharField(max_length=20)
  132
+	class Category(models.Model):
  133
+    	parent = models.ForeignKey('self', blank=True, null=True)
  134
+    	name = models.CharField(max_length=20)
132 135
     
133  
-    def __unicode__(self):
134  
-        return self.name
  136
+    	def __unicode__(self):
  137
+        	return self.name
135 138
     
136  
-    def get_title(self):
137  
-        return self.name
  139
+    	def get_title(self):
  140
+        	return self.name
138 141
     
139  
-    def get_absolute_url(self):
140  
-        return reverse('category_view', args=[self.pk])
  142
+    	def get_absolute_url(self):
  143
+        	return reverse('category_view', args=[self.pk])
141 144
     
142  
-try:
143  
-    mptt.register(Category)
144  
-except mptt.AlreadyRegistered:
145  
-    pass
  145
+	try:
  146
+    	mptt.register(Category)
  147
+	except mptt.AlreadyRegistered:
  148
+    	pass
146 149
     
147 150
 It is encouraged to use mptt for the tree structure because of performance considerations.
148 151
 The objects provided must adhere to the following Structure:
@@ -150,10 +153,10 @@ The objects provided must adhere to the following Structure:
150 153
 they must have a:
151 154
 
152 155
 get_title function
153  
-get_absolute_url function
  156
+get\_absolute\_url function
154 157
 childrens array with all its children inside (the s at the end is done on purpose because children is already taken by mptt)
155 158
 
156  
-Be sure that get_title and get_absolute_url doesn't trigger any queries when called in the template or otherwise you 
  159
+Be sure that get\_title and get\_absolute\_url doesn't trigger any queries when called in the template or otherwise you 
157 160
 may have some serious performance and DB problems with lot of queries
158 161
 
159 162
 It may be wise to cache the output of get_nodes. For this you may need to write a wrapper Class because of dynamic content the pickle class can't handle
@@ -162,40 +165,40 @@ If you want to display some static pages in the navigation like "login" for exam
162 165
 Properties of Navigation Nodes in the template
163 166
 ----------------------------------------------
164 167
 
165  
-node.is_leaf_node:
  168
+	{{ node.is_leaf_node }}
166 169
 
167 170
 Is it the last in the tree? If true it doesn't have any children
168 171
 Comes normally from mptt
169 172
 
170  
-node.level:
  173
+	{{ node.level }}
171 174
 
172 175
 The level of the node. Starts at 0
173 176
 
174  
-node.get_absolute_url:
  177
+	{{ node.get_absolute_url }}
175 178
 
176 179
 The absolute url of the node
177 180
 
178  
-node.get_title:
  181
+	{{ node.get_title }}
179 182
 
180 183
 The title in the current language of the node
181 184
 
182  
-node.selected:
  185
+	{{ node.selected }}
183 186
 
184 187
 If true this node is the current selected/active at this URL
185 188
  
186  
-node.ancestor:
  189
+	{{ node.ancestor }}
187 190
 
188 191
 If true this node is an ancestor of the current selected node.
189 192
 
190  
-node.sibling
  193
+	{{ node.sibling }}
191 194
 
192 195
 If true this node is a sibling of the current selected node.
193 196
 
194  
-node.descendant:
  197
+	{{ node.descendant }}
195 198
 
196 199
 If true this node is a descendant of the current selected node.
197 200
 
198  
-node.soft_root
  201
+	{{ node.soft_root }}
199 202
 
200 203
 If true this node is softroot
201 204
 
@@ -208,11 +211,11 @@ This feature is useful if you have big navigation trees with a lot of sites and
208 211
 
209 212
 To enable it put the following to your settings.py
210 213
 
211  
-CMS_SOFTROOT = True
  214
+	CMS_SOFTROOT = True
212 215
 
213 216
 Now you can mark a page as softroot in the advanced Tab of the Page Settings.
214 217
 
215  
-page_id_url
  218
+page\_id\_url
216 219
 -----------
217 220
 
218 221
 This templatetag return the url of a page that has reverse_id.
@@ -222,9 +225,9 @@ Goto this page in the admin and enter a reverse_id in the advanced tab.
222 225
 
223 226
 Example: "help"
224 227
 
225  
-now you can place the page_id_url in your template like this.
  228
+now you can place the page\_id\_url in your template like this.
226 229
 
227  
-<a href="{% page_id_url "help" %}">help</a>
  230
+	<a href="{% page_id_url "help" %}">help</a>
228 231
 
229 232
 
230 233
  
73  cms/docs/plugins.txt → cms/docs/plugins.md
Source Rendered
@@ -3,14 +3,14 @@ Plugins
3 3
 
4 4
 Lets say we have the following gallery model:
5 5
 
6  
-class Gallery(models.Model):
7  
-	name = models.CharField(max_length=30)
  6
+	class Gallery(models.Model):
  7
+		name = models.CharField(max_length=30)
8 8
 	
9  
-class Picture(models.Model):
10  
-	image = models.ImageField(upload_to="uploads/images/")
11  
-	description = models.CharField(max_lenght=60)
  9
+	class Picture(models.Model):
  10
+		image = models.ImageField(upload_to="uploads/images/")
  11
+		description = models.CharField(max_lenght=60)
12 12
 
13  
-And we wan't to display this gallery between two text blocks.
  13
+And we want to display this gallery between two text blocks.
14 14
 We can do this with a cms plugin.
15 15
 To create a cms plugin you need two components: A CMSPlugin model and a cms_plugins.py
16 16
 
@@ -19,10 +19,10 @@ Plugin Model
19 19
 
20 20
 First create a model that links the gallery:
21 21
 
22  
-from cms.models import CMSPlugin
  22
+	from cms.models import CMSPlugin
23 23
 
24  
-class GalleryPlugin(CMSPlugin):
25  
-	gallery = models.ForeignKey(Gallery)
  24
+	class GalleryPlugin(CMSPlugin):
  25
+		gallery = models.ForeignKey(Gallery)
26 26
 	
27 27
 
28 28
 Be sure to extend from CMSPlugin instead of models.Model.
@@ -36,55 +36,56 @@ After that create in the application folder (the same the models.py is) a cms_pl
36 36
 
37 37
 In there write the following:
38 38
 
39  
-from cms.plugin_base import CMSPluginBase
40  
-from cms.plugin_pool import plugin_pool
41  
-from models import GalleryPlugin
42  
-from django.utils.translation import ugettext as _
  39
+	from cms.plugin_base import CMSPluginBase
  40
+	from cms.plugin_pool import plugin_pool
  41
+	from models import GalleryPlugin
  42
+	from django.utils.translation import ugettext as _
43 43
 
44  
-class CMSGalleryPlugin(CMSPluginBase):
45  
-	model = GalleryPlugin
46  
-    name = _("Gallery")
47  
-    render_template = "gallery/gallery.html"
  44
+	class CMSGalleryPlugin(CMSPluginBase):
  45
+		model = GalleryPlugin
  46
+    	name = _("Gallery")
  47
+    	render_template = "gallery/gallery.html"
48 48
     
49  
-    def render(self, context, instance, placeholder):
50  
-        return context.upa{'gallery':instance.gallery, 'placeholder':placeholder}
  49
+    	def render(self, context, instance, placeholder):
  50
+        	return context.upa{'gallery':instance.gallery, 'placeholder':placeholder}
51 51
     
52  
-plugin_pool.register_plugin(CMSGalleryPlugin)		
  52
+	plugin_pool.register_plugin(CMSGalleryPlugin)		
53 53
 
54  
-model:
  54
+### model ###
55 55
 
56 56
 is the CMSPlugin Model we created earlier
57 57
 If you don't need a model because you just want to display some template logic use CMSPlugin from cms.models as the model instead.
58 58
 
59  
-name:
  59
+### name ###
60 60
 
61 61
 will be displayed in the plugin editor
62 62
 
63  
-render_template:
  63
+### render_template ###
64 64
 
65 65
 will be rendered with the context returned by the render function
66 66
 
  67
+### render ###
  68
+
67 69
 the render function takes 3 arguments:
68 70
 
69  
-context:
  71
+**context**:
70 72
 
71 73
 the context of the template placeholder was placed.
72 74
 
73  
-instance:
  75
+**instance**:
74 76
 
75 77
 the instance of the GalleryPlugin model
76 78
 
77  
-placeholder:
  79
+**placeholder**:
78 80
 
79 81
 the name of the placeholder this plugin appears.
80 82
 It is normally a good idea to give the placeholder to the template so you can style
81 83
 the content differently in the template based on which placholder it is placed.
82 84
 
83  
-
84 85
 If you want to process forms in the render function or if you wan't to see if the user is logged in you may want to access the request. 
85 86
 You can accomplish this simply with:
86 87
 
87  
-request = context['request']
  88
+	request = context['request']
88 89
 
89 90
 because the request will always be in the context as the requescontext processor is required by the cms
90 91
 
@@ -92,9 +93,9 @@ Template
92 93
 --------
93 94
 now create a gallery.html template in templates/gallery/ and write the following in there.
94 95
 
95  
-{% for image in gallery.picture_set.all %}
96  
-	<img src="{{ image.image.url }}" alt="{{ image.description }}" />
97  
-{% endfor %}
  96
+	{% for image in gallery.picture_set.all %}
  97
+		<img src="{{ image.image.url }}" alt="{{ image.description }}" />
  98
+	{% endfor %}
98 99
 
99 100
 Now go into the admin create a gallery and afterwards go into a page and add a gallery plugin and some pictures should appear in your page.
100 101
 
@@ -105,21 +106,23 @@ CMSGalleryPlugin can be even further customized:
105 106
 
106 107
 you can add some other attributes:
107 108
 
108  
-form_template:
  109
+### form_template ###
109 110
 
110 111
 the template used to render the form.
111 112
 It is good practice to extend from "admin/cms/page/plugin_forms.html" So you get the same look and feel.
112 113
 
113  
-form:
  114
+### form ###
114 115
 
115 116
 A reference to a Form that will be displayed if you edit the plugin. If nothing is provided a model form of the model
116 117
 will be used.
117 118
 
118  
-placeholders:
  119
+### placeholders ###
119 120
 
120 121
 a tuple of placeholder names this plugin can appear:
121 122
 
122 123
 For exmaple you have 3 placeholders: content, right-column, left-column
123 124
 And you want that your plugin only appears in either the left or right column but no in content:
124 125
 
125  
-add this to your plugin: placeholders = ('right-column', 'left-column')
  126
+add this to your plugin: 
  127
+	
  128
+	placeholders = ('right-column', 'left-column')

0 notes on commit 2b550e3

Please sign in to comment.
Something went wrong with that request. Please try again.