Author: batiste.bieler
Date: Sun Jun  7 08:22:30 2009
New Revision: 551

Added:
    wiki/WriteYourOwnWidget.wiki

Log:
Created wiki page through web user interface.

Added: wiki/WriteYourOwnWidget.wiki
==============================================================================
--- (empty file)
+++ wiki/WriteYourOwnWidget.wiki        Sun Jun  7 08:22:30 2009
@@ -0,0 +1,37 @@
+#summary Example for creating and using a custom widget.
+
+=How to create your own widget for the CMS's admin=
+
+A basic widget could look like this:
+
+{{{
+from django.forms import Textarea
+from django.utils.safestring import mark_safe
+
+class CustomTextarea(Textarea):
+    """class Media:
+        js = ['path to your javascript']
+        css = {
+            'all': ['path to your CSS']
+        }"""
+
+    def __init__(self, attrs=None):
+        attrs = {'class': 'custom-textarea'}
+        super(CustomTextarea, self).__init__(attrs)
+
+    def render(self, name, value, attrs=None):
+        rendered = super(CustomTextarea, self).render(name, value, attrs)
+        return mark_safe("""Take a look at \
+                example.widgets.CustomTextarea<br>""") \
+                + rendered
+}}}
+
+
+Create a file named widget somewhere in one of your project's application  
and then you can simply use the placeholder syntax. If your widget is in  
the `example.widgets` module the syntax should look like this :
+
+{{{
+{% placeholder custom_widget_example on current_page with  
example.widgets.CustomTextarea parsed  %}
+}}}
+
+
+More example of widgets are available in `pages.admin.widgets`
\ No newline at end of file

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to