kender
kender

Reputation: 87261

Default content plugin in django-cms

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?

Upvotes: 5

Views: 3203

Answers (5)

digi604
digi604

Reputation: 1090

django CMS 3.0 supports default plugins for placeholders:

http://docs.django-cms.org/en/stable/reference/configuration.html#placeholder-default-plugins

Upvotes: 2

jacdeh
jacdeh

Reputation: 21

There's a simple way to achieve the same functionality:

Provide a number of "prototype pages", one for each combination of page template and instantiated plugins you want to be available to the customer.

Have the customer create new pages by copying the template pages (can be done via the copy icon in the pages admin) rather than making a new page from scratch. In this way the required plugins will already be there, even with a default content if you wish.

Upvotes: 2

Wernight
Wernight

Reputation: 37668

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.

Upvotes: 1

John Mee
John Mee

Reputation: 52333

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"
    )

Upvotes: 1

sayplastic
sayplastic

Reputation: 24

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)
})

Upvotes: 0

Related Questions