views:

275

answers:

3

Hi, I started using django CMS project. It's great, built with modular design kept in mind... but what actually our customer wants is more simplicity:

Here, in django CMS every page can contain many content 'plugins' - be it text, image, or other. But the customer wants to have a text plugin active, selected and created automatically for every new page - and work on that text field. It's something that's just simpler for them to use.

Anyone have done something like that before with this CMS system? Or, any other simple CMS solutions for django you could recommend?

A: 

The fastest, but probably not the most elegant way is:

  • write a script that mimicks user behavior when selecting and adding text plugin from a dropdown;
  • override PageAdmin to include our script.

It goes like this:

# anywhere in your project, for example, site/admin.py
from cms.models import Page
from cms.admin.pageadmin import PageAdmin

class ModPageAdmin(PageAdmin):
    class Media:
        js = ('js/cms.page.js',)

admin.site.unregister(Page)
admin.site.register(Page, ModPageAdmin)

# in MEDIA_URL/js/cms.page.js
$(document).ready(function(){
    ph = $("div.form-row.main") // replace "main" with your placeholder name, lower-case
    $("select", ph).val('TextPlugin')
    window.setTimeout(function(){ $("span.add-plugin", ph).click() }, 500)
})
sayplastic
A: 

Do you even need the CMS module?

The most basic of CMS's is nearly trivial using out-of-the-box django:

class ContentPage(models.Model):
   title = models.CharField(max_length=100)
   content = models.TextField()
   slug = models.SlugField()

def view_page(request, slug='home'):
   return render_to_response('content.html',
        { 'page':  ContentPage.objects.get(slug=slug) },
        context_instance=RequestContext(request)
    )

Just use the django admin to get started. But if you want more, and not give them the admin it's pretty easy to knock up a form/action to edit these fields.

If you need wysiwyg editing add tinymce to the form template. Something like:

 <script type="text/javascript" src="{{MEDIA_URL}}tiny_mce/tiny_mce.js"></script>
 <script type="text/javascript">
 tinyMCE.init({...

or (as mentioned by 'sayplastic') if you are still editing pages via through the admin you can attach Tiny to that too

class Media:
    js = (
        settings.MEDIA_URL + "jquery/jquery.js",
        settings.MEDIA_URL + "tiny_mce/tiny_mce.js",
        settings.MEDIA_URL + "js/admin.js"
    )
John Mee
+1  A: 

Their is also FeinCMS which provides similar page tree editor and simpler block by default. It's more customizable.

If you don't need the tree editor, Django has built-in flatpages which are very simple.

Wernight