### Navigation

- index
- modules |
- next |
- previous |
- FeinCMS 1.7.4 documentation »

# Page module

## Models

class `feincms.module.page.models.``BasePageManager`

  The page manager. Only adds new methods, does not modify standard Django manager behavior in any way.

  `best_match_for_path`(path, raise404=False)

    Return the best match for a path. If the path as given is unavailable, continues to search by chopping path components off the end.

    Tries hard to avoid unnecessary database lookups by generating all possible matching URL prefixes and choosing the longest match.

    Page.best_match_for_path(‘/photos/album/2008/09’) might return the page with url ‘/photos/album/’.

  `for_request`(request, raise404=False, best_match=False, setup=False)

    Return a page for the request

    Does not hit the database more than once for the same request.

    Examples:

        Page.objects.for_request(request, raise404=True, best_match=False)

    Defaults to raising a `DoesNotExist` exception if no exact match could be determined.

  `in_navigation`()

    Returns active pages which have the `in_navigation` flag set.

  `page_for_path`(path, raise404=False)

    Return a page for a path. Optionally raises a 404 error if requested.

    Example:

        Page.objects.page_for_path(request.path)

  `toplevel_navigation`()

    Returns top-level navigation entries.

class `feincms.module.page.models.``Page`(*args, **kwargs)

  Page(id, lft, rght, tree_id, level, active, title, slug, parent_id, in_navigation, override_url, redirect_to, _cached_url)

  `get_absolute_url`(*moreargs, **morekwargs)

    Return the absolute URL of this page.

## Request and response processors

`feincms.module.page.processors.``debug_sql_queries_response_processor`(verbose=False, file=<open file '<stderr>', mode 'w' at 0x557da0d0>)

  Attaches a handler which prints the query count (and optionally all individual queries which have been executed) on the console. Does nothing if `DEBUG = False`.

  Example:

      from feincms.module.page import models, processors
      models.Page.register_response_processor(
          processors.debug_sql_queries_response_processor(verbose=True),
          )

`feincms.module.page.processors.``etag_request_processor`(page, request)

  Short-circuits the request-response cycle if the ETag matches.

`feincms.module.page.processors.``etag_response_processor`(page, request, response)

  Response processor to set an etag header on outgoing responses. The Page.etag() method must return something valid as etag content whenever you want an etag header generated.

`feincms.module.page.processors.``extra_context_request_processor`(page, request)

  Fills `request._feincms_extra_context` with a few useful variables.

`feincms.module.page.processors.``frontendediting_request_processor`(page, request)

  Sets the frontend editing state in the cookie depending on the `frontend_editing` GET parameter and the user’s permissions.

`feincms.module.page.processors.``redirect_request_processor`(page, request)

  Returns a `HttpResponseRedirect` instance if the current page says a redirect should happen.

## Admin classes

## Sitemap module

class `feincms.module.page.sitemap.``PageSitemap`(navigation_only=False, max_depth=0, changefreq=None, queryset=None, filter=None, extended_navigation=False, *args, **kwargs)

  The PageSitemap can be used to automatically generate sitemap.xml files for submission to index engines. See http://www.sitemaps.org/ for details.

  `items`()

    Consider all pages that are active and that are not a redirect

  `priority`(obj)

    The priority is staggered according to the depth of the page in the site. Top level get highest priority, then each level is decreased by per_level.

## Extensions

### Page excerpts

Add an excerpt field to the page.

### Navigation extensions

Extend or modify the navigation with custom entries.

This extension allows the website administrator to select an extension which processes, modifies or adds subnavigation entries. The bundled `feincms_nav` template tag knows how to collect navigation entries, be they real Page instances or extended navigation entries.

class `feincms.module.page.extensions.navigation.``NavigationExtension`

  Base class for all navigation extensions.

  The name attribute is shown to the website administrator.

  `children`(page, **kwargs)

    This is the method which must be overridden in every navigation extension.

    It receives the page the extension is attached to, the depth up to which the navigation should be resolved, and the current request object if it is available.

class `feincms.module.page.extensions.navigation.``PagePretender`(**kwargs)

  A PagePretender pretends to be a page, but in reality is just a shim layer that implements enough functionality to inject fake pages eg. into the navigation tree.

  For use as fake navigation page, you should at least define the following parameters on creation: title, url, level. If using the translation extension, also add language.

  `get_children`()

    overwrite this if you want nested extensions using recursetree

class `feincms.module.page.extensions.navigation.``TypeRegistryMetaClass`(name, bases, attrs)

  You can access the list of subclasses as <BaseClass>.types

### Related pages

Add a many-to-many relationship field to relate this page to other pages.

### Symlinked page content

This introduces a new page type, which has no content of its own but inherits all content from the linked page.

### Flexible page titles

Sometimes, a single title is not enough, you’d like subtitles, and maybe differing titles in the navigation and in the <title>-tag. This extension lets you do that.

## Extensions not specific to the page module

### Creation and modification timestamps

Track the modification date for objects.

`feincms.module.extensions.changedate.``pre_save_handler`(sender, instance, **kwargs)

  Intercept attempts to save and insert the current date and time into creation and modification date fields.

### Content type count denormalization

Track the content types for pages. Instead of gathering the content types present in each page at run time, save the current state at saving time, thus saving at least one DB query on page delivery.

`feincms.module.extensions.ct_tracker.``single_pre_save_handler`(sender, instance, **kwargs)

  Clobber the _ct_inventory attribute of this object

`feincms.module.extensions.ct_tracker.``tree_post_save_handler`(sender, instance, **kwargs)

  Clobber the _ct_inventory attribute of this object and all sub-objects on save.

### Date-based publishing

Allows setting a date range for when the page is active. Modifies the active() manager method so that only pages inside the given range are used in the default views and the template tags.

Depends on the page class having a “active_filters” list that will be used by the page’s manager to determine which entries are to be considered active.

`feincms.module.extensions.datepublisher.``datepublisher_response_processor`(page, request, response)

  This response processor is automatically added when the datepublisher extension is registered. It sets the response headers to match with the publication end date of the page so that upstream caches and the django caching middleware know when to expunge the copy.

`feincms.module.extensions.datepublisher.``format_date`(d, if_none='')

  Format a date in a nice human readable way: Omit the year if it’s the current year. Also return a default value if no date is passed in.

`feincms.module.extensions.datepublisher.``granular_now`(n=None)

  A datetime.now look-alike that returns times rounded to a five minute boundary. This helps the backend database to optimize/reuse/cache its queries by not creating a brand new query each time.

  Also useful if you are using johnny-cache or a similar queryset cache.

### Featured items

Add a “featured” field to objects so admins can better direct top content.

### Search engine optimization fields

Add a keyword and a description field which are helpful for SEO optimization.

### Translations

This extension adds a language field to every page. When calling the request processors the page’s language is activated. Pages in secondary languages can be said to be a translation of a page in the primary language (the first language in settings.LANGUAGES), thereby enabling deeplinks between translated pages.

It is recommended to activate `django.middleware.locale.LocaleMiddleware` so that the correct language will be activated per user or session even for non-FeinCMS managed views such as Django’s administration tool.

`feincms.module.extensions.translations.``translation_set_language`(request, select_language)

  Set and activate a language, if that language is available.

`feincms.module.extensions.translations.``user_has_language_set`(request)

  Determine whether the user has explicitely set a language earlier on. This is taken later on as an indication that we should not mess with the site’s language settings, after all, the user’s decision is what counts.

### Navigation

- index
- modules |
- next |
- previous |
- FeinCMS 1.7.4 documentation »