Template tags

FeinCMS tags

feincms.templatetags.feincms_tags.feincms_frontend_editing(cms_obj, request)

{% feincms_frontend_editing feincms_page request %}

feincms.templatetags.feincms_tags.feincms_prefill_entry_list(queryset, attrs, region=None)

{% feincms_prefill_entry_list queryset “authors,richtextcontent_set” [region] %}

feincms.templatetags.feincms_tags.feincms_render_content(parser, token)

{% feincms_render_content contentblock request %}

feincms.templatetags.feincms_tags.feincms_render_region(parser, token)

{% feincms_render_region feincms_page “main” request %}

feincms.templatetags.feincms_tags.show_content_type_selection_widget(context, region)

{% show_content_type_selection_widget region %}

Thumbnail filters

feincms.templatetags.feincms_thumbnail.cropscale(filename, size='200x200')

Scales the image down and crops it so that its size equals exactly the size passed (as long as the initial image is bigger than the specification).

feincms.templatetags.feincms_thumbnail.thumbnail(filename, size='200x200')

Creates a thumbnail from the image passed, returning its path:

{{ object.image|thumbnail:"400x300" }}
OR
{{ object.image.name|thumbnail:”400x300” }}

You can pass either an ImageField, FileField or the name but not the url attribute of an ImageField or FileField.

The dimensions passed are treated as a bounding box. The aspect ratio of the initial image is preserved. Images aren’t blown up in size if they are already smaller.

Both width and height must be specified. If you do not care about one of them, just set it to an arbitrarily large number:

{{ object.image|thumbnail:"300x999999" }}

Page-module specific tags

class feincms.module.page.templatetags.feincms_page_tags.LanguageLinksNode(tag_name, in_var_name, var_name, args)
{% feincms_languagelinks for feincms_page as links [args] %}

This template tag needs the translations extension.

Arguments can be any combination of:

  • all or existing: Return all languages or only those where a translation exists
  • excludecurrent: Excludes the item in the current language from the list
  • request=request: The current request object, only needed if you are using AppContents and need to append the “extra path”

The default behavior is to return an entry for all languages including the current language.

Example:

{% feincms_languagelinks for entry as links all,excludecurrent %}
{% for key, name, link in links %}
    <a href="{% if link %}{{ link }}{% else %}/{{ key }}/{% endif %}">{% trans name %}</a>
{% endfor %}
class feincms.module.page.templatetags.feincms_page_tags.NavigationNode(tag_name, in_var_name, var_name, args)

Return a list of pages to be used for the navigation

level: 1 = toplevel, 2 = sublevel, 3 = sub-sublevel depth: 1 = only one level, 2 = subpages too extended: run navigation extension on returned pages, not only on top-level node

If you set depth to something else than 1, you might want to look into the tree_info template tag from the mptt_tags library.

Example:

{% feincms_navigation of feincms_page as sublevel level=2,depth=1 %}
{% for p in sublevel %}
    <a href="{{ p.get_absolute_url }}">{{ p.title }}</a>
{% endfor %}
class feincms.module.page.templatetags.feincms_page_tags.ParentLinkNode(tag_name, in_var_name, args)

{% feincms_parentlink of feincms_page level=1 %}

class feincms.module.page.templatetags.feincms_page_tags.TranslatedPageNode(tag_name, in_var_name, var_name, args)
{% feincms_translatedpage for feincms_page as feincms_transpage language=en %}
{% feincms_translatedpage for feincms_page as originalpage %}
{% feincms_translatedpage for some_page as translatedpage language=feincms_page.language %}

This template tag needs the translations extension.

Returns the requested translation of the page if it exists. If the language argument is omitted the primary language will be returned (the first language specified in settings.LANGUAGES).

Note: To distinguish between a bare language code and a variable we check whether settings LANGUAGES contains that code – so naming a variable “en” will probably not do what is intended.

feincms.module.page.templatetags.feincms_page_tags.feincms_breadcrumbs(page, include_self=True)

Generate a list of the page’s ancestors suitable for use as breadcrumb navigation.

By default, generates an unordered list with the id “breadcrumbs” - override breadcrumbs.html to change this.

{% feincms_breadcrumbs feincms_page %}
feincms.module.page.templatetags.feincms_page_tags.is_equal_or_parent_of(page1, page2)

Determines whether a given page is equal to or the parent of another page. This is especially handy when generating the navigation. The following example adds a CSS class current to the current main navigation entry:

{% for page in navigation %}
    <a {% if page|is_equal_or_parent_of:feincms_page %}class="mark"{% endif %}>
        {{ page.title }}</a>
{% endfor %}
feincms.module.page.templatetags.feincms_page_tags.is_parent_of(page1, page2)

Determines whether a given page is the parent of another page

Example:

{% if page|is_parent_of:feincms_page %} ... {% endif %}
feincms.module.page.templatetags.feincms_page_tags.is_sibling_of(page1, page2)

Determines whether a given page is a sibling of another page

{% if page|is_sibling_of:feincms_page %} ... {% endif %}

ApplicationContent tags

feincms.templatetags.applicationcontent_tags.feincms_render_region_appcontent(page, region, request)

Render only the application content for the region

This allows template authors to choose whether their page behaves differently when displaying embedded application subpages by doing something like this:

{% if not in_appcontent_subpage %}
    {% feincms_render_region feincms_page "main" request %}
{% else %}
    {% feincms_render_region_appcontent feincms_page "main" request %}
{% endif %}
feincms.templatetags.fragment_tags.fragment(parser, token)

Appends the given content to the fragment. Different modes (replace, append) are available if specified.

Either:

{% fragment request "title" %} content ... {% endfragment %}

or:

{% fragment request "title" (prepend|replace|append) %} content ... {% endfragment %}
feincms.templatetags.fragment_tags.get_fragment(parser, token)

Fetches the content of a fragment.

Either:

{% get_fragment request "title" %}

or:

{% get_fragment request "title" as title %}
feincms.templatetags.fragment_tags.has_fragment(request, identifier)

Returns the content of the fragment, despite its name:

{% if request|has_fragment:"title" %} ... {% endif %}

Tags not part of the public API

These tags aren’t guaranteed to stay or to be kept backwards compatible in any way. They should be considered for internal use only.

feincms.templatetags.feincms_admin_tags.post_process_fieldsets(fieldset)

Removes a few fields from FeinCMS admin inlines, those being id, DELETE and ORDER currently.

Table Of Contents

Previous topic

Shortcuts

Next topic

Translations

This Page