django-cms中的默认内容插件

时间:2023-01-31 08:51:23

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:

我开始使用django CMS项目。它非常棒,采用模块化设计而构建......但实际上我们的客户想要的是更简单:

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.

在这里,在django CMS中,每个页面都可以包含许多内容“插件” - 无论是文本,图像还是其他。但是客户想要为每个新页面自动激活,选择和创建文本插件 - 并在该文本字段上工作。这对他们来说更简单。

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

有没有人在使用这个CMS系统之前做过类似的事情?或者,您可以推荐任何其他简单的django CMS解决方案?

5 个解决方案

#1


2  

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.

让客户通过复制模板页面创建新页面(可以通过页面管理员中的复制图标完成),而不是从头开始创建新页面。通过这种方式,所需的插件已经存在,即使您希望使用默认内容也是如此。

#2


2  

django CMS 3.0 supports default plugins for placeholders:

django CMS 3.0支持占位符的默认插件:

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

#3


1  

Do you even need the CMS module?

你甚至需要CMS模块吗?

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

最基本的CMS使用开箱即用的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.

只需使用django管理员即可开始使用。但是如果你想要更多,而不是给他们管理员,那么很容易敲响一个表单/动作来编辑这些字段。

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

如果你需要wysiwyg编辑添加tinymce到表单模板。就像是:

 <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

或者(如'sayplastic'所述)如果您仍然通过管理员编辑页面,您也可以附加Tiny

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

#4


1  

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

它们也是FeinCMS,它默认提供类似的页面树编辑器和更简单的块。它更具可定制性。

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

如果你不需要树编辑器,Django有内置的平面页面,非常简单。

#5


0  

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.
  • 覆盖PageAdmin以包含我们的脚本。

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

#1


2  

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.

让客户通过复制模板页面创建新页面(可以通过页面管理员中的复制图标完成),而不是从头开始创建新页面。通过这种方式,所需的插件已经存在,即使您希望使用默认内容也是如此。

#2


2  

django CMS 3.0 supports default plugins for placeholders:

django CMS 3.0支持占位符的默认插件:

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

#3


1  

Do you even need the CMS module?

你甚至需要CMS模块吗?

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

最基本的CMS使用开箱即用的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.

只需使用django管理员即可开始使用。但是如果你想要更多,而不是给他们管理员,那么很容易敲响一个表单/动作来编辑这些字段。

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

如果你需要wysiwyg编辑添加tinymce到表单模板。就像是:

 <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

或者(如'sayplastic'所述)如果您仍然通过管理员编辑页面,您也可以附加Tiny

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

#4


1  

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

它们也是FeinCMS,它默认提供类似的页面树编辑器和更简单的块。它更具可定制性。

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

如果你不需要树编辑器,Django有内置的平面页面,非常简单。

#5


0  

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.
  • 覆盖PageAdmin以包含我们的脚本。

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