django-cms 中的默认内容插件

发布于 2024-08-28 20:24:49 字数 303 浏览 12 评论 0原文

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

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

有人用这个 CMS 系统做过类似的事情吗?或者,您可以推荐任何其他简单的 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

安穩 2024-09-04 20:24:50

有一种简单的方法可以实现相同的功能:

提供许多“原型页面”,每个页面模板和实例化插件的组合对应您希望客户可用的页面模板和实例化插件。

让客户通过复制模板页面(可以通过页面管理中的复制图标完成)来创建新页面,而不是从头开始创建新页面。这样,所需的插件就已经存在,如果您愿意的话,甚至可以使用默认内容。

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.

一杯敬自由 2024-09-04 20:24:50

您还需要 CMS 模块吗?

使用开箱即用的 django,最基本的 CMS 几乎是微不足道的:

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

只需使用 django admin 即可开始。但是,如果您想要更多,并且不给他们管理员,那么很容易敲出表单/操作来编辑这些字段。

如果您需要所见即所得编辑,请将tinymce添加到表单模板中。类似:

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

或者(如“say Plastic”所述)如果您仍在通过管理员编辑页面,您也可以将 Tiny 附加到该页面

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

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"
    )
寄人书 2024-09-04 20:24:50

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

如果您不需要树编辑器,Django 内置了 flatpages< /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.

友谊不毕业 2024-09-04 20:24:50

最快但可能不是最优雅的方法是:

  • 编写一个脚本来模仿用户从下拉列表中选择和添加文本插件时的行为;
  • 覆盖 PageAdmin 以包含我们的脚本。

事情是这样的:

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

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)
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文