Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Breadcrumbs #470

Open
vxsx opened this issue Sep 1, 2017 · 0 comments
Open

Breadcrumbs #470

vxsx opened this issue Sep 1, 2017 · 0 comments

Comments

@vxsx
Copy link
Member

vxsx commented Sep 1, 2017

It's usually a problem creating breadcrumbs for newsblog, i believe it's something that should be included in the package.

Currently on (3.4.4) I'm using this snippet, which is a bit of a monstrosity:

{% block extend_breadcrumb %}
    <li class="child">
        <a href="{% url 'pages-root' %}">{% page_attribute "page_title" "home" %}</a>
    </li>
    {% for page in request.current_page.get_ancestors.all %}
        <li class="child">
            <a href="{% page_url page %}">{% page_attribute "page_title" page %}</a>
        </li>
    {% endfor %}
    {% if article or newsblog_author or newsblog_year or newsblog_month or newsblog_category or newsblog_tag %}
        <li class="child">
            <a href="{% page_url request.current_page %}">{% page_attribute "page_title" request.current_page %}</a>
        </li>
    {% else %}
        <li class="child active">
            {% page_attribute "page_title" request.current_page %}
        </li>
    {% endif %}
    {% if newsblog_author %}
        <li class="child active">
            {{ newsblog_author.name }}
        </li>
    {% endif %}
    {% if article %}
        <li class="child active">
            {{ article.title }}
        </li>
    {% endif %}
    {% if newsblog_year and not newsblog_month %}
        <li class="child active">
            {{ newsblog_year }}
        </li>
    {% endif %}
    {% if newsblog_year and newsblog_month %}
        <li class="child">
            <a href="{% namespace_url 'article-list-by-year' year=newsblog_year namespace=request.resolver_match.namespace default='' %}">{{ newsblog_year }}</a>
        </li>
    {% endif %}
    {% if newsblog_month and newsblog_archive_date %}
        <li class="child active">
            {{ newsblog_archive_date|date:"F" }}
        </li>
    {% endif %}
    {% if newsblog_tag %}
        <li class="child active">{% trans "Tag" %}: {{ newsblog_tag }}</li>
    {% endif %}
    {% if newsblog_category %}
        <li class="child active">{{ newsblog_category }}</li>
    {% endif %}
{% endblock %}

This would be much better as a template tag or directly integrated into show_breadcrumb cms template tag.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant