Closed bart7782 closed 1 year ago
Hello there,
Yes this can be done by editing one of the themes slightly. The template file responsible for displaying the blog index is index.twig. If using the Blossom theme, we can display a list of post titles on the index by editing themes/blossom/pages/index.twig as follows:
{% extends "layouts" ~ DIR ~ "default.twig" %}
{% block content %}
{% if reason is not defined %}{# Some modules define reason in error states #}
{% for post in posts.paginated %}
<h2 class="post {{ post.feather }}{{ post.pinned ? ' pinned' : '' }}">
<a href="{{ post.url() }}" rel="bookmark" title="{{ 'Permanent link to “%s”' | translate | format(post.title() | striptags | fix(true)) }}">
{{ post.title() }}
</a>
</h2>
{% else %}
<div class="ribbon">
<h3 class="ribbon">{{ "No posts" | translate }}</h3>
</div>
{% endfor %}
{% else %}
<div class="ribbon">
<h3 class="ribbon">{{ reason }}</h3>
</div>
{% endif %}
{% endblock %}
The only changes are to the statements between {% for post in posts.paginated %}
and {% else %}
. Instead of calling a Twig template to display the content of each post, we display its title inside a <h2>
heading with a hyperlink to view it. We add class="post"
to the heading element because the Cascade module will use this to load additional content for infinite scrolling.
Hi, Thank you so much for the quick response. I tried using your tweak but it seems like it didn't change anything. I am using the Umbra theme so i edited ../themes/umbra/pages/index.twig. I copied your exact code but it seems like nothing changed. I also tried restarting my webserver+database but unsurprisingly it did not change anything either. In the chyrp settings > routes i have Homepage unchecked.
This is likely caused by the Twig cache. You can delete the contents of includes/caches/twig or enable DEBUG mode to disable Twig caching while you work on your theme.
This fixed it. Thanks! This also explained why something else I tried to change didn't work. I tried to change some of buttons in the header and the cache also prevented that from updating.
Thank you for this amazing project. It's blazing fast and you are even providing good support for it.
I want to display a list of post titles on the homepage ordered by latest post. Is this possible to do with chyrp-lite? I just want to see the post titles and have them link to the actual posts.