nephila / djangocms-blog

django CMS blog application - Support for multilingual posts, placeholders, social network meta tags and configurable apphooks
https://djangocms-blog.readthedocs.io
BSD 3-Clause "New" or "Revised" License
391 stars 192 forks source link

categories list now work #755

Open hoomanjavadpoor opened 10 months ago

hoomanjavadpoor commented 10 months ago

Hi everyone I can't get the list of all categories in my template do you have any idea?

<!-- Categories Start -->
<div class="row block_categories block_sidebar">
    <div class="wighet-title">{% trans "Categories" %}</div>
    <div class="row block_sidebar_content">
    <div class="sidebar_categories">
        <!-- Categories Url Start -->
        <ul>
        {% for category in categories %}
        <li>
            <a href="{{ category.get_absolute_url }}">{{ category.name }}</a>
            <span>{{ category.count }}</span>
        </li>
        {% endfor %}
        </ul>
        <!-- Categories Url End -->
    </div>
    </div>
</div>
<!-- Categories End -->

It's return an empty list

Also same problem with tags

<!-- Sidebar Tags Start -->
<div class="row block_categories block_sidebar">
    <div class="wighet-title">{% trans "Tags" %}</div>
    <div class="row block_sidebar_content">
    <div class="sidebar_categories">
        {% for tag in tags %}
        <a href="{% url 'djangocms_blog:posts-tagged' tag=tag.slug %}" class="skrolurl">{{ tag.name }} <span>{{ tag.count }}</span></a>
        {% endfor %}
    </div>
    </div>
</div>
<!-- Sidebar Tags End -->
protoroto commented 9 months ago

Hi! Where are you trying to get the categories list? In which template / plugin?

hoomanjavadpoor commented 9 months ago

Hi tnx for your response i try to place it in post_list.html

protoroto commented 9 months ago

Ok, because that template is used in a few places: is it the main blog page, or are you using a plugin? Anyway, you don't have categories (or tags) in the context there, so if you want to display the list of posts categories, you should use BlogCategoryPlugin for the categories, and BlogTagsPlugin for the tags.