Django Basic CMS declare rather simple models: Page Content and PageAlias.
Those Django models have the following relations:
Placeholder module, that’s where the smart things happen.
A contact PlaceholderNode example.
A PlaceholderNode that saves one file on disk.
PAGE_UPLOAD_ROOT setting define where to save the file.
A PlaceholderNode that saves one image on disk.
PAGE_UPLOAD_ROOT setting define where to save the image.
This template node is used to output and save page content and dynamically generate input fields in the admin.
Parameters: |
|
---|
alias of CharField
Get eventual extra data for this placeholder from the admin form. This method is called when the Page is saved in the admin and passed to the placeholder save method.
The field that will be shown within the admin.
Given the name of a placeholder return a Widget subclass like Textarea or TextInput.
Output the content of the PlaceholdeNode in the template.
Actually save the placeholder data into the Content object.
alias of TextInput
A youtube PlaceholderNode, just here as an example.
alias of VideoWidget
Parse the PlaceholderNode parameters.
Return a tuple with the name and parameters.
Page CMS page_tags template tags
Fake CSRF node for django 1.1.1
Get content node
get_page Node
Get Pages with given tag node
Load page node.
Method that parse the contactplaceholder template tag.
Method that parse the fileplaceholder template tag.
Retrieve a Content object and insert it into the template’s context.
Example:
{% get_content page_object "title" as content %}
You can also use the slug of a page:
{% get_content "my-page-slug" "title" as content %}
Syntax:
{% get_content page type [lang] as name %}
Parameters: |
|
---|
Retrieve a page and insert into the template’s context.
Example:
{% get_page "news" as news_page %}
Parameters: |
|
---|
Return Pages with given tag
Syntax:
{% get_pages_with_tag <tag name> as <varname> %}
Method that parse the imageplaceholder template tag.
Load the navigation pages, lang, and current_page variables into the current context.
Example:
<ul>
{% load_pages %}
{% for page in pages_navigation %}
{% pages_menu page %}
{% endfor %}
</ul>
Method that parse the placeholder template tag.
Syntax:
{% placeholder <name> [on <page>] [with <widget>] [parsed] [as <varname>] %}
Example usage:
{% placeholder about %}
{% placeholder body with TextArea as body_text %}
{% placeholder welcome with TextArea parsed as welcome_text %}
{% placeholder teaser on next_page with TextArea parsed %}
Method that parse the imageplaceholder template tag.
Return a Page object from a slug or an id.
Fitler that return True if the page has any content in a particular language.
Parameters: |
|
---|
Tell if all the page content has been updated since the last change of the official version (settings.LANGUAGE_CODE)
This is approximated by comparing the last modified date of any content in the page, not comparing each content block to its corresponding official language version. That allows users to easily make “do nothing” changes to any content block when no change is required for a language.
Render the admin table of pages.
Tags
Render a “dynamic” tree menu, with all nodes expanded which are either ancestors or the current page itself.
Override pages/dynamic_tree_menu.html if you want to change the design.
Parameters: |
|
---|
Render a nested list of all the descendents of the given page, including this page.
Parameters: |
|
---|
Get the parent page of the given page and render a nested list of its child pages. Good for rendering a secondary menu.
Parameters: |
|
---|
Get the root page of the given page and render a nested list of all root’s children pages. Good for rendering a secondary menu.
Parameters: |
|
---|
Show the url of a page in the right language
Example
{% show_absolute_url page_object %}
You can also use the slug of a page:
{% show_absolute_url "my-page-slug" %}
Keyword arguments: :param page: the page object, slug or id :param lang: the wanted language (defaults to settings.PAGE_DEFAULT_LANGUAGE)
Display a content type from a page.
Example:
{% show_content page_object "title" %}
You can also use the slug of a page:
{% show_content "my-page-slug" "title" %}
Or even the id of a page:
{% show_content 10 "title" %}
Parameters: |
|
---|
Render the last 10 revisions of a page content with a list using the pages/revisions.html template
Display slug with level by language.
Django CMS come with a set of ready to use widgets that you can enable in the admin via a placeholder tag in your template.
CKEditor widget.
EditArea is a html syntax coloured widget.
A RichTextarea widget.
A youtube Widget for the admin.
Given a list of rendered widgets (as strings), it inserts an HTML linebreak between them.
Returns a Unicode string representing the HTML for the whole lot.
WYMEditor widget.
markItUpHTML widget.
markItUpMarkdown widget.
markItUpRest widget.
This model contain the status, dates, author, template. The real content of the page can be found in the Content model.
Get the calculated status of the page based on Page.publication_date, Page.publication_end_date, and Page.status.
Return a list of latest published Content for a particluar language.
Parameters: | language – wanted language, |
---|
Return a python dict representation of this page for use as part of a JSON export.
Return all the current content of this page into a string.
This is used by the haystack framework to build the search index.
Alias for get_url_path.
This method is only there for backward compatibility and will be removed in a near futur.
Parameters: | language – the wanted url language. |
---|
Return a QuerySet of published children page
Return the complete slug of this page by concatenating all parent’s slugs.
Parameters: | language – the wanted slug language. |
---|
Shortcut method for retrieving a piece of page content
Parameters: |
|
---|
Return a QuerySet of published children page ordered by publication date.
Return a list of all used languages for this page.
Get the template of this page if defined or the closer parent’s one if defined or pages.settings.PAGE_DEFAULT_TEMPLATE otherwise.
Get the template name of this page if defined or if a closer parent has a defined template or pages.settings.PAGE_DEFAULT_TEMPLATE otherwise.
Alias for get_complete_slug.
This method is only there for backward compatibility and will be removed in a near futur.
Parameters: | language – the wanted url language. |
---|
Return the URL’s path component. Add the language prefix if PAGE_USE_LANGUAGE_PREFIX setting is set to True.
Parameters: | language – the wanted url language. |
---|
Return True if the page have broken links to other pages into the content.
Invalidate cached data for this page.
Return True if this page is the first root pages.
Used in the admin menu to create the left margin.
Override the default save method.
Return the slug of the page depending on the given language.
Parameters: |
|
---|
Display the slug of the page prepended with insecable spaces equal to simluate the level of page in the hierarchy.
Return the title of the page depending on the given language.
Parameters: |
|
---|
The second pass of PageManager.create_and_update_from_json_data used to update the redirect_to field.
Returns a messages list to be appended to the messages from the first pass.
Return a QuerySet of valid targets for moving a page into the tree.
Parameters: | perms – the level of permission of the concerned user. |
---|
Return True if the page is visible on the frontend.
Page manager provide several filters to obtain pages QuerySet that respect the page attributes and project settings.
Create or update page based on python dict d loaded from JSON data. This applies all data except for redirect_to, which is done in a second pass after all pages have been imported,
user is the User instance that will be used if the author can’t be found in the DB.
returns (page object, created, messages).
created is True if this was a new page or False if an existing page was updated.
messages is a list of strings warnings/messages about this import
Creates a QuerySet of drafts using the page’s Page.publication_date.
Creates a QuerySet of expired using the page’s Page.publication_end_date.
Filter the given pages QuerySet to obtain only published page.
Return a Page according to the page’s path.
Creates a QuerySet of the hidden pages.
Creates a QuerySet of the published root pages.
Return a QuerySet of pages that are published on the site defined by the SITE_ID setting.
Parameters: | site_id – specify the id of the site object to filter with. |
---|
Create a population of Page for testing purpose.
Creates a QuerySet of published Page.
Return a QuerySet of pages without parent.
This class based view get the root pages for navigation and the current page to display if there is any.
All is rendered with the current page’s template.
Deal with the multiple corner case of choosing the language.
Call the PAGE_EXTRA_CONTEXT function if there is one.
Get the pages that are at the root level.
Just there in case you have special business logic.
Return True if the user is staff.
Return the appropriate page according to the path.
Check for redirections.
A block of content, tied to a Page, for a particular language
Content manager methods
Create a Content for a particular page and language only if the content has changed from the last time.
Parameters: |
|
---|
Gets the latest content string for a particular page, language and placeholder.
Parameters: |
|
---|
Gets the latest published Content for a particular page, language and placeholder type.
Returns the latest Content slug object that match the given slug for the current site domain.
Parameters: | slug – the wanted slug. |
---|
Return all page’s id matching the given slug. This function also returns pages that have an old slug that match.
Parameters: | slug – the wanted slug. |
---|
Sanitize a string in order to avoid possible XSS using html5lib.
Set or create a Content for a particular page and language.
Parameters: |
|
---|
PageAlias manager.
Resolve a request to an alias. returns a PageAlias if the url matches no page at all. The aliasing system supports plain aliases (/foo/bar) as well as aliases containing GET parameters (like index.php?page=foo).
Parameters: |
|
---|
A collection of functions for Page CMS
Export all the content from the published pages into po files. The files will be automatically updated with the new content if you run the command again.
Return a list of PlaceholderNode found in the given template.
Parameters: | template_name – the name of the template file |
---|
Import all the content updates from the po files into the pages.
Attept to create/update pages from JSON string json. user is the user that will be used when creating a page if a page’s original author can’t be found. preferred_lang is the language code of the slugs to include in error messages (defaults to settings.PAGE_DEFAULT_LANGUAGE).
Returns (errors, pages_created) where errors is a list of strings and pages_created is a list of: (page object, created bool, messages list of strings) tuples.
If any errors are detected there the error list will contain information for the user and no pages will be created/updated.
Return a normalized url with trailing and without leading slash.
>>> normalize_url(None)
'/'
>>> normalize_url('/')
'/'
>>> normalize_url('/foo/bar')
'/foo/bar'
>>> normalize_url('foo/bar')
'/foo/bar'
>>> normalize_url('/foo/bar/')
'/foo/bar'
Return a JSON string export of the pages in queryset.
Check if an import of d will succeed, and return errors.
errors is a list of strings. The import should proceed only if errors is empty.
Page CMS functions related to the request object.
Return the most obvious language according the request.
Build a request mock up that is used in to render the templates in the most fidel environement as possible.
This fonction is used in the get_placeholders method to render the input template and search for the placeholder within.
Return the page’s slug
>>> get_slug('/test/function/')
function
Gets a valid template from different sources or falls back to the default template.
Make sure the decorated view gets the essential pages variables.
Return the remainin part of the path
>>> remove_slug('/test/some/function/')
test/some
Pages admin views
Switch the status of a page.
Get the content for a particular page
Render pages table for ajax function.
Modify the content of a page.
Move the page to the requested target, at the given position.
Render the children of the requested page with the sub_menu template.
Traduction helper.