<commit_before>===================================
HOWTO: Use the built-in page module
===================================

FeinCMS is primarily a system to work with lists of content blocks which
you can assign to arbitrary other objects. You do not necessarily have to
use it with a hierarchical page structure, but that's the most common use
case of course. Being able to put content together in small manageable
pieces is interesting for other uses too, i.e. for weblog entries where you
have rich text content interspersed with images, videos or maybe even galleries.

To activate the page module, you need to follow the instructions in
installation.txt and afterwards add ``feincms.module.page'' to your
``INSTALLED_APPS''.

You need to create some content models. No models are created by default,
because there is no possibility to unregister models. A sane default might
be to create ``ImageContent``and ``RichTextContent'' models; you can do this
by adding the following lines somewhere into your project, for example in a
``models.py'' file that will be processed anyway:

::

    from feincms.module.page.models import Page
    from feincms.content.richtext.models import RichTextContent
    from feincms.content.image.models import ImageContent

    Page.register_templates({
        'key': 'base',
        'title': 'Standard template',
        'path': 'base.html',
        'regions': (
            ('main', 'Main content area'),
            ('sidebar', 'Sidebar', 'inherited'),
            ),
        })

    Page.create_content_type(RichTextContent)
    Page.create_content_type(ImageContent)


It will be a good idea most of the time to register the RichTextContent
first, because it's the most used content type for many applications. The
content type dropdown will contain content types in the same order as they
were registered.


Setting up the admin interface
==============================

The customized admin interface code is contained inside the ``ModelAdmin''
subclass, so you do not need to do anything special here. You only need to set
``FEINCMS_ADMIN_MEDIA'' as described in the installation documentation.


Wiring up the views
===================

Just add the following lines to your ``urls.py'' to get a catch-all URL pattern:

::

    urlpatterns += patterns('',
        url(r'^(.*)$', 'feincms.views.base.handler'),
    )


There isn't a possibility (yet?) to specify a homepage; the needs are
often different, and it's not a big problem writing your own home page view.
I often do the following:

::

    urlpatterns += patterns('',
        url(r'^$', 'myproject.views.home'),

        # include urls for other django applications
<commit_msg>Add a note to the page howto about the TinyMCE dependency<commit_after>===================================
HOWTO: Use the built-in page module
===================================

FeinCMS is primarily a system to work with lists of content blocks which
you can assign to arbitrary other objects. You do not necessarily have to
use it with a hierarchical page structure, but that's the most common use
case of course. Being able to put content together in small manageable
pieces is interesting for other uses too, i.e. for weblog entries where you
have rich text content interspersed with images, videos or maybe even galleries.

To activate the page module, you need to follow the instructions in
installation.txt and afterwards add ``feincms.module.page'' to your
``INSTALLED_APPS''.

You need to create some content models. No models are created by default,
because there is no possibility to unregister models. A sane default might
be to create ``ImageContent``and ``RichTextContent'' models; you can do this
by adding the following lines somewhere into your project, for example in a
``models.py'' file that will be processed anyway:

::

    from feincms.module.page.models import Page
    from feincms.content.richtext.models import RichTextContent
    from feincms.content.image.models import ImageContent

    Page.register_templates({
        'title': 'Standard template',
        'path': 'base.html',
        'regions': (
            ('main', 'Main content area'),
            ('sidebar', 'Sidebar', 'inherited'),
            ),
        })

    Page.create_content_type(RichTextContent)
    Page.create_content_type(ImageContent)


It will be a good idea most of the time to register the RichTextContent
first, because it's the most used content type for many applications. The
content type dropdown will contain content types in the same order as they
were registered.


Setting up the admin interface
==============================

The customized admin interface code is contained inside the ``ModelAdmin''
subclass, so you do not need to do anything special here. You only need to set
``FEINCMS_ADMIN_MEDIA'' as described in the installation documentation.

If you use the RichTextContent, you need to download TinyMCE and set
``TINYMCE_JS_URL'' to the absolute path to the main javascript file.


Wiring up the views
===================

Just add the following lines to your ``urls.py'' to get a catch-all URL pattern:

::

    urlpatterns += patterns('',
        url(r'^(.*)$', 'feincms.views.base.handler'),
    )


There isn't a possibility (yet?) to specify a homepage; the needs are
often different, and it's not a big problem writing your own home page view.
I often do the following:

::

    urlpatterns += patterns('',
        url(r'^$', 'myproject.views.home'),

        # include urls for other django applications

{'fraction_non_alphanumeric': 0.11187545257060101, 'fraction_numerical': 0.0, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '69474', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1359, 'n_words': 690}