Daily Dev Notes 2024/06/05

More work on the template tags tonight. I'm getting closer to my goal of having a similar template structure to the old WordPress Classic blogs. In particular, I'm using this template file as my inspiration: https://themes.svn.wordpress.org/classic/1.6/index.php

The key aim I'm trying to achieve is that you should be able to develop a theme without needing to understand Django views, or which views have which context. The addition of the have_posts tag moves me closer to this goal. Now, instead of needing to know the specific context fields the views will be sending, you can use this syntax instead:

      {% have_posts as posts %}
      {% for post in posts %}

        {% category_name "h1" pre_text="View Posts in the " post_text=" Category" %}
        {% author_name "h1" pre_text="View Posts by " %}

        <article>
          <header>
            <h1>{% post_title_link %}</h1>
            <p>By {% post_author_link %}. {% post_date_link %}</p>
          </header>
          <section>
            {% post_content %}
          </section>
          <footer>
            <p>Categories: {% post_categories_link "span" "badge" %}</p>
          </footer>
        </article>

      {% empty %}

        <p>No posts available.</p>

      {% endfor %}

Overall, I'm pretty happy with where this is heading. But still have some really fundamental things to sort out too - next on the list must be pagination.