Template Tags¶
Template tags for displaying stories and related content.
Load the template tags with:
{% load djangocms_stories %}
Available Tags¶
namespace_url¶
- namespace_url(view_name, *args, namespace='djangocms_stories', **kwargs)¶
Returns the URL for a given namespace and view name.
Usage:
- Parameters:
context (dict) – template context
namespace (str) – app namespace
view_name (str) – name of the view to reverse
- Returns:
URL for the specified view in the given namespace
- Return type:
str
Reverse a URL within the stories namespace:
{% load djangocms_stories %}
{% namespace_url "posts-latest" as latest_url %}
<a href="{{ latest_url }}">All stories</a>
media_plugins¶
- media_plugins(context, post_content)¶
Extract
djangocms_stories.media.base.MediaAttachmentPluginMixinplugins from themediaplaceholder of the provided post.They can be rendered with
render_plugintemplatetag:- Parameters:
context (dict) – template context
post (
djangocms_stories.models.Post) – post instance
- Returns:
list of
djangocms_stories.media.base.MediaAttachmentPluginMixinplugins- Return type:
List[djangocms_stories.media.base.MediaAttachmentPluginMixin]
Extract media plugins from a post’s media placeholder:
{% load djangocms_stories %}
{% media_plugins post_content as media_content %}
{% for plugin in media_content %}
{% render_plugin plugin %}
{% endfor %}
media_images¶
- media_images(context, post_content, main=True)¶
Extract images of the given size from all the
djangocms_stories.media.base.MediaAttachmentPluginMixinplugins in themediaplaceholder of the provided post.Support
djangocms-videoposterfield in case the plugin does not implementMediaAttachmentPluginMixinAPI.Usage:
- Parameters:
context (dict) – template context
post (
djangocms_stories.models.Post) – post instancemain (bool) – retrieve main image or thumbnail
- Returns:
list of images urls
- Return type:
list
Extract image URLs from media plugins:
{% load djangocms_stories %}
{% media_images post_content as previews %}
{% for preview in previews %}
<img src="{{ preview }}" alt="Media preview" />
{% endfor %}
absolute_url¶
- GetAbsoluteUrl¶
alias of
GetAbsoluteUrl
Get the absolute URL for a post content object, with toolbar-awareness:
{% load djangocms_stories %}
{% absolute_url post_content as post_url %}
<a href="{{ post_url }}">{{ post_content.title }}</a>