Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
an introduction
about myself



  •Name: Patrick Lauber
  •Place: Zürich, Switzerland
  •Age: 29
  •Profession: CTO of tigermedia.ch
  •Ni...
history



  •         .ch

   •django-cms 1.0 (django 0.96) menu,
    performance

   •django-page-cms (django 1.0, mptt,...
the parts



   • pages
   • plugins
   • menu
   • frontedit
   • permissions
   • publisher
   • i18n-urls
pages

 •title
 •drag&drop
 •mptt
 •published?
 •in menu?
 •meta info
 •template
plugins

 •your content
 •mix it
 •placeholders
 •reorder
 •drag & drop
 •copy / paste
plugins



              {% load cms_tags %}

           {% placeholder header %}

          {% placeholder leftcolumn %}
...
plugins



           already built in:

            text, picture,
              link, file,
          flash, googlemap,
  ...
plugins




                 get more at:

          www.django-cms.org/extensions
menu

 •Construct any menu the
  design requires with two
   template tags

 •breadcrumbs
 •menus package
menu




          {% load menu_tags %}

       {% show_menu 0 100 0 100 %}


                                 • From Leve...
menu




                 {% load menu_tags %}

            {% show_menu 0 100 0 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 0 100 0 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 0 100 0 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 0 100 0 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 0 100 1 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 0 100 1 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 1 100 1 100 %}


                                ...
menu




                 {% load menu_tags %}

            {% show_menu 1 100 1 100 %}


                                ...
menu




                 {% load menu_tags %}

    {% show_menu 1 100 1 100 "my_menu.html" %}


                         ...
menu




            {% load menu_tags %}

   {% show_sub_menu 100 "my_menu.html" %}
menu




             {% load menu_tags %}

   {% show_breadcrumb 0 "my_breadcrumb" %}
frontedit

 • Edit Plugins directly in
   frontend

 • Add “?edit” to url to
   enable

 • Customers love it
permissions

 •create users with inherited
  permissions

 •allow / disallow: moving,
  editing, adding,
   advanced setti...
publisher

 •Moderate content changes
 •get notified
 • content onlydeleted if
   published /
                gets

   appr...
i18n-urls

 • Language prefix
   /de/your_url/

 • middleware based
 • no changesurls, apps your
   templates,
            ...
integrating it

  • How your own project.
    into
         to integrate the cms



  • It’s just an app.
  1. Menus

  2....
menus

 • Addmenu own entries to
   the
       your



 • yourapp/menu.py
 • entries will be attached to
   the root.
menus – menu.py


    from menus.base import Menu, NavigationNode
	   from menus.menu_pool import menu_pool
	   from djang...
attach menus

 • Inherits from instead of
   CMSAttachMenu
   Menu

 • Selectadvanced settings to
   page
          your m...
attach menus – menu.py


    from   menus.base import Menu, NavigationNode
	   from   menus.menu_pool import menu_pool
	  ...
menu modifiers

 • modify the whole menu
   tree

 • add or change properties
   of NavigationNodes

 • rearrange trees
 • ...
menu modifiers


    from menus.base import Modifier
	   from menus.menu_pool import menu_pool

	   class MyModifier(Modifi...
app-hooks

 • attach whole apps to a
   page.

 • myapp/cms_app.py
 • urls.py gets attached to a
   page url

 • needs ser...
app-hooks – cms_app.py


    from   cms.app_base import CMSApp
	   from   cms.apphook_pool import apphook_pool
	   from   ...
app-hooks – urls.py


    from django.conf.urls.defaults import *

	   urlpatterns = patterns("myapp.views",
	       url(r...
app-hooks
 • If page has german url as well:
   /meine_seite/

 • app is available at:
   /en/mypage/
   /de/meine_seite/
...
app-hooks – cms_app.py


    from myapp.menu import CategoryMenu
	
	   class MyApphook(CMSApp):
	       name = _("My App")...
app-hooks – models.py


    from django.db import models
	   from django.core.urlresolvers import reverse
	   import mptt
...
app-hooks – menu.py


    from   menus.base import NavigationNode
	   from   menus.menu_pool import menu_pool
	   from   d...
custom plugins

 •your data as a plugin
 •teasers for your app data
 •yourapp/cms_plugins.py
 • model inherits from
   CMS...
custom plugins – models.py

  	
  class Gallery(models.Model):
  	 name = models.CharField(max_length=30)
  	
  class Pict...
custom plugins – models.py


  from cms.models import CMSPlugin
  	
  class GalleryPlugin(CMSPlugin):
  	 gallery = models...
custom plugins – cms_plugins.py


  from cms.plugin_base import CMSPluginBase
  from cms.plugin_pool import plugin_pool
  ...
custom plugins

 • CMSPluginBase extends
   from ModelAdmin

 • text enabled plugins
 • plugins are a tree (mptt)
 • plugi...
placeholders

 • use the plugin system in
   your own apps.

 • works with frontedit :)
placeholders - models.py

  	 	
  from django.db import models
  from cms.models.fields import PlaceholderField
  	
  clas...
placeholders - admin.py


  from django.contrib import admin
  from cms.admin.placeholderadmin import PlaceholderAdmin
  f...
placeholders - template.html


  {% load placeholder_tags %}
  	
  {% render_placeholder myblog_instance.content %}
the future

 • 2.1 release
   • sprints → RC1?
 • 2.2
   • page extenders
   • more modularization
       • tree
       • ...
Thank you

   •Questions?




   •contact: digi@treepy.com
   •www.django-cms.org
   •http://github.com/digi604/django-cms...
Upcoming SlideShare
Loading in …5
×

Django cms.key

5,521 views

Published on

An in depth introduction to django-cms

Published in: Technology, Business
  • Dating for everyone is here: ❤❤❤ http://bit.ly/39mQKz3 ❤❤❤
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ♥♥♥ http://bit.ly/39mQKz3 ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Django cms.key

  1. 1. an introduction
  2. 2. about myself •Name: Patrick Lauber •Place: Zürich, Switzerland •Age: 29 •Profession: CTO of tigermedia.ch •Nick: digi604
  3. 3. history • .ch •django-cms 1.0 (django 0.96) menu, performance •django-page-cms (django 1.0, mptt, placeholders) •django-cms 2.0 (plugins) •django-cms 2.1 (menus, placeholder 2.0, frontedit)
  4. 4. the parts • pages • plugins • menu • frontedit • permissions • publisher • i18n-urls
  5. 5. pages •title •drag&drop •mptt •published? •in menu? •meta info •template
  6. 6. plugins •your content •mix it •placeholders •reorder •drag & drop •copy / paste
  7. 7. plugins {% load cms_tags %} {% placeholder header %} {% placeholder leftcolumn %} {% placeholder content %} {% placeholder footer %}
  8. 8. plugins already built in: text, picture, link, file, flash, googlemap, inherit, snippet, teaser twitter, video
  9. 9. plugins get more at: www.django-cms.org/extensions
  10. 10. menu •Construct any menu the design requires with two template tags •breadcrumbs •menus package
  11. 11. menu {% load menu_tags %} {% show_menu 0 100 0 100 %} • From Level • To Level • Inactive Levels • Active Levels
  12. 12. menu {% load menu_tags %} {% show_menu 0 100 0 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  13. 13. menu {% load menu_tags %} {% show_menu 0 100 0 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  14. 14. menu {% load menu_tags %} {% show_menu 0 100 0 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  15. 15. menu {% load menu_tags %} {% show_menu 0 100 0 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  16. 16. menu {% load menu_tags %} {% show_menu 0 100 1 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  17. 17. menu {% load menu_tags %} {% show_menu 0 100 1 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  18. 18. menu {% load menu_tags %} {% show_menu 1 100 1 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  19. 19. menu {% load menu_tags %} {% show_menu 1 100 1 100 %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  20. 20. menu {% load menu_tags %} {% show_menu 1 100 1 100 "my_menu.html" %} • From Level • Current Page • To Level • Root Nodes & • Inactive Levels Siblings • Active Levels
  21. 21. menu {% load menu_tags %} {% show_sub_menu 100 "my_menu.html" %}
  22. 22. menu {% load menu_tags %} {% show_breadcrumb 0 "my_breadcrumb" %}
  23. 23. frontedit • Edit Plugins directly in frontend • Add “?edit” to url to enable • Customers love it
  24. 24. permissions •create users with inherited permissions •allow / disallow: moving, editing, adding, advanced settings, sites, moderation
  25. 25. publisher •Moderate content changes •get notified • content onlydeleted if published / gets approved
  26. 26. i18n-urls • Language prefix /de/your_url/ • middleware based • no changesurls, apps your templates, needed to
  27. 27. integrating it • How your own project. into to integrate the cms • It’s just an app. 1. Menus 2. Attach Menus 3. Navigation Modifiers 4. App-hooks 5. Custom Plugins 6. Placeholders
  28. 28. menus • Addmenu own entries to the your • yourapp/menu.py • entries will be attached to the root.
  29. 29. menus – menu.py from menus.base import Menu, NavigationNode from menus.menu_pool import menu_pool from django.utils.translation import ugettext_lazy as _ class MyMenu(Menu): def get_nodes(self, request): nodes = [] n = NavigationNode(_("login"), reverse("auth_login"), 1) n2 = NavigationNode(_("admin"), reverse("admin:root"), 2) n3 = NavigationNode(_("My list"), "/mylist/", 3) n4 = NavigationNode(_("My sublist"), "/mylist/sublist/", 4, 3) nodes.append(n) nodes.append(n2) nodes.append(n3) nodes.append(n4) return nodes menu_pool.register_menu(MyMenu)
  30. 30. attach menus • Inherits from instead of CMSAttachMenu Menu • Selectadvanced settings to page your menu in the attach. • Needs a name
  31. 31. attach menus – menu.py from menus.base import Menu, NavigationNode from menus.menu_pool import menu_pool from django.utils.translation import ugettext_lazy as _ from cms.menu_bases import CMSAttachMenu class MyMenu(CMSAttachMenu): name = _("My Menu") def get_nodes(self, request): nodes = [] n = NavigationNode(_("login"), reverse("auth_login"), 1) n2 = NavigationNode(_("admin"), reverse("admin:root"), 2) n3 = NavigationNode(_("My list"), "/mylist/", 3) n4 = NavigationNode(_("My sublist"), "/mylist/sublist/", 4, 3) nodes.append(n) nodes.append(n2) nodes.append(n3) nodes.append(n4) return nodes menu_pool.register_menu(MyMenu)
  32. 32. menu modifiers • modify the whole menu tree • add or change properties of NavigationNodes • rearrange trees • applied in 3 situations: • pre cut • post cut • breadcrumb
  33. 33. menu modifiers from menus.base import Modifier from menus.menu_pool import menu_pool class MyModifier(Modifier): """ Counts the nodes """ def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb): if post_cut or breadcrumb: return nodes count = 0 for node in nodes: node.counter = count count += 1 return nodes menu_pool.register_modifier(MyModifier)
  34. 34. app-hooks • attach whole apps to a page. • myapp/cms_app.py • urls.py gets attached to a page url • needs server restart after changes :(
  35. 35. app-hooks – cms_app.py from cms.app_base import CMSApp from cms.apphook_pool import apphook_pool from django.utils.translation import ugettext_lazy as _ from myapp.menu import MyMenu class MyApphook(CMSApp): name = _("My App") urls = ["myapp.urls"] apphook_pool.register(MyApphook)
  36. 36. app-hooks – urls.py from django.conf.urls.defaults import * urlpatterns = patterns("myapp.views", url(r"^$', "main_view", name="app_main"), url(r"^sublevel/$", "sample_view", name="app_sublevel"), ) • Page URL: /mypage/ • /mypage/ will be handled by main_view • /mypage/sublevel/ will be handled by sample_view • plugins from page are available in app templates
  37. 37. app-hooks • If page has german url as well: /meine_seite/ • app is available at: /en/mypage/ /de/meine_seite/ • reverse("main_view") or {% url main_view %}will choose current language • to choose manually: • reverse("de:main_view") • reverse("en:main_view") • {% url de:main_view %}
  38. 38. app-hooks – cms_app.py from myapp.menu import CategoryMenu class MyApphook(CMSApp): name = _("My App") urls = ["myapp.urls"] menus = [CategoryMenu] apphook_pool.register(MyApphook) • If your app has a menu, attach it as well • reverse in menu gets the language namespace as well
  39. 39. app-hooks – models.py from django.db import models from django.core.urlresolvers import reverse import mptt class Category(models.Model): parent = models.ForeignKey("self", blank=True, null=True) name = models.CharField(max_length=20) def __unicode__(self): return self.name def get_absolute_url(self): return reverse("category_view", args=[self.pk]) try: mptt.register(Category) except mptt.AlreadyRegistered: pass
  40. 40. app-hooks – menu.py from menus.base import NavigationNode from menus.menu_pool import menu_pool from django.utils.translation import ugettext_lazy as _ from cms.menu_bases import CMSAttachMenu from myapp.models import Category class CategoryMenu(CMSAttachMenu): name = _("My Category Menu") def get_nodes(self, request): nodes = [] for category in Category.objects.all().order_by("tree_id", "lft"): nodes.append( NavigationNode( category.name, category.pk, category.parent_id ) ) return nodes menu_pool.register_menu(CategoryMenu)
  41. 41. custom plugins •your data as a plugin •teasers for your app data •yourapp/cms_plugins.py • model inherits from CMSPlugin
  42. 42. custom plugins – models.py class Gallery(models.Model): name = models.CharField(max_length=30) class Picture(models.Model): gallery = models.ForeignKey(Gallery) image = models.ImageField(upload_to="uploads/images/") description = models.CharField(max_length=60)
  43. 43. custom plugins – models.py from cms.models import CMSPlugin class GalleryPlugin(CMSPlugin): gallery = models.ForeignKey(Gallery)
  44. 44. custom plugins – cms_plugins.py from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool from models import GalleryPlugin from django.utils.translation import ugettext as _ class CMSGalleryPlugin(CMSPluginBase): model = GalleryPlugin name = _("Gallery") render_template = "cms/plugins/gallery.html" def render(self, context, instance, placeholder): context.update({ "gallery":instance.gallery, "object":instance, "placeholder":placeholder }) return context plugin_pool.register_plugin(CMSGalleryPlugin)
  45. 45. custom plugins • CMSPluginBase extends from ModelAdmin • text enabled plugins • plugins are a tree (mptt) • plugin media • plugin rules in your settings.py • Plugin Context Processors (add Context to render) • Plugin Processors (Modify output of plugins)
  46. 46. placeholders • use the plugin system in your own apps. • works with frontedit :)
  47. 47. placeholders - models.py from django.db import models from cms.models.fields import PlaceholderField class MyBlog(models.Model): title = models.CharField(max_length=100) slug = models.SlugField(max_length=100) content = PlaceholderField("blog_content")
  48. 48. placeholders - admin.py from django.contrib import admin from cms.admin.placeholderadmin import PlaceholderAdmin from models import MyBlog class MyBlogAdmin(PlaceholderAdmin): prepopulated_fields = {"slug": ("title",)} #just for the slug field admin.site.register(MyBlog, MyBlogAdmin)
  49. 49. placeholders - template.html {% load placeholder_tags %} {% render_placeholder myblog_instance.content %}
  50. 50. the future • 2.1 release • sprints → RC1? • 2.2 • page extenders • more modularization • tree • permissions • publisher • frontedit
  51. 51. Thank you •Questions? •contact: digi@treepy.com •www.django-cms.org •http://github.com/digi604/django-cms-2.0/ •#django-cms @ irc.freenode.net some pictures from: zazzle.com, thechive.com, google image search :)

×