#################### Customizing Stories #################### Templates ========= djangocms-stories comes with minimal templates without any styling. You can override these templates in the classical Django way (see the `Django template loading documentation `_) by placing your own versions in your project's ``templates/djangocms_stories/`` directory. This allows you to add your own markup and styling to customize the appearance of your stories. Default template directory structure ------------------------------------ .. code-block:: djangocms_stories/ templates/ djangocms_stories/ base.html post_archive.html post_detail.html post_list.html category_list.html post_author_list.html includes/ post_meta.html post_header.html post_footer.html Story List Template ------------------- Create your custom ``templates/djangocms_stories/post_list.html`` based on the default example:: {% extends "djangocms_stories/base.html" %} {% load i18n easy_thumbnails_tags cms_tags %} {% block content_blog %}
{% block blog_title %}

{% if author %}{% trans "Articles by" %} {{ author.get_full_name }} {% elif archive_date %}{% trans "Archive" %} – {% if month %}{{ archive_date|date:'F' }} {% endif %}{{ year }} {% elif tagged_entries %}{% trans "Tag" %} – {{ tagged_entries|capfirst }} {% elif category %}{% trans "Category" %} – {% render_model category "name" %}{% endif %}

{% endblock %} {% for post_content in postcontent_list %}

{{ post_content.title }}

{{ post_content.abstract }}

{% if post_content.post.main_image %} {% thumbnail post_content.post.main_image "300x200" crop upscale as thumb %} {{ post_content.title }} {% endif %}
{% empty %}

{% trans "No article found." %}

{% endfor %} {% if is_paginated %} {% endif %}
{% endblock %} These are the context variables available in the **Story List Template (post_list.html)** - ``postcontent_list`` - List of PostContent objects (translated content) - ``page_obj`` - Pagination object when paginated - ``paginator`` - Paginator instance - ``is_paginated`` - Boolean indicating if content is paginated - ``author`` - Author object when filtering by author - ``archive_date`` - Date object when viewing archives - ``year``, ``month`` - Integer values for archive filtering - ``tagged_entries`` - Tag name when filtering by tag - ``category`` - Category object when filtering by category Story Detail Template ---------------------- Create ``templates/djangocms_stories/post_detail.html``:: {% extends "djangocms_stories/base.html" %} {% load i18n easy_thumbnails_tags cms_tags %} {% block title %}{{ post_content.title }}{% endblock %} {% block content_blog %}

{% render_model post_content "title" "title" %}

{% if post_content.subtitle %}

{% render_model post_content "subtitle" "subtitle" %}

{% endif %} {% block post_meta %}
{% if post_content.post.author %} {{ post_content.post.author.get_full_name }} {% endif %}
{% endblock %}
{% if post_content.post.main_image %}
{% thumbnail post_content.post.main_image "800x400" crop upscale as main_image %} {{ post_content.post.main_image.default_alt_text }}
{% endif %} {% if post_content.post.app_config.use_placeholder and post_content.content %}
{% placeholder "content" %}
{% else %}
{% render_model post_content "post_text" "post_text" "" "safe" %}
{% endif %} {% if post_content.post.tags.exists %}
{% for tag in post_content.post.tags.all %} {{ tag.name }} {% endfor %}
{% endif %} {% if post_content.post.related.exists %} {% endif %}
{% endblock %} These are the context variables available in the **Story Detail Template (post_detail.html)** - ``post_content`` - PostContent object (translated content) - ``meta`` - Meta object with SEO information - ``TRUNCWORDS_COUNT`` - Number of words for truncation .. seealso:: For more detailed information on creating your own templates, refer to the :ref:`custom_templates` chapter. Important Template Notes ------------------------ :class:`~djangocms_stories.models.PostContent` vs :class:`~djangocms_stories.models.Post` Objects** djangocms-stories uses django CMS' `grouper-content structure `_ for multi-language architecture where: - :class:`~djangocms_stories.models.Post` - The main model containing language-independent data (dates, author, images, etc.) - :class:`~djangocms_stories.models.PostContent` - Contains translated content (title, subtitle, abstract, post_text, etc.) In templates, you typically work with ``post_content`` objects and access the underlying ``Post`` via ``post_content.post``. **Placeholder vs Rich Text Fields** Content can be rendered in two ways depending on the ``use_placeholder`` setting: - **Placeholders**: ``{% placeholder "content" %}`` - Allows CMS plugins - **Rich Text**: ``{% render_model post_content "post_text" %}`` - Simple rich text field **Template Inheritance** Templates can extend ``djangocms_stories/base.html`` which provides the basic structure and common blocks like ``content_blog``. It may also be customized according to your needs by overriding specific blocks or adding new ones. Settings Configuration ====================== Customize behavior through Django settings: Story Configuration ------------------- :: # Number of stories per page STORIES_PAGINATION = 20 # Enable/disable features STORIES_USE_ABSTRACT = True STORIES_USE_PLACEHOLDER = True STORIES_USE_RELATED = True .. seealso:: For more detailed information on available settings, refer to the :ref:`settings` chapter.