getgrav / grav-plugin-archives

Grav Archives Plugin
https://getgrav.org
MIT License
8 stars 12 forks source link

List with years and not with month and years. #38

Closed prikle closed 2 months ago

prikle commented 2 months ago

Hello

I am in despair. What settings do I have to make to get a list of years?

I would like only the years to be displayed and not the months and years.

Thank you!

rhukster commented 2 months ago

I have added some info in the README.md regarding this, and also released a 2.0.3 version that includes this partials/archives-year.html.twig example thats mentioned in the README: https://github.com/getgrav/grav-plugin-archives/tree/2.0.3?tab=readme-ov-file#archives-by-year-example

btw, if you update to the 2.0.3 version, you can use the included partials/archives-year.html.twig by modifing Typhoon's partials/sidebar.html.twig to include it rather than the default partials/archives.html.twig:

{% include 'partials/archives-year.html.twig' with {'base_url':new_base_url} %}

Alternatively you can just copy the partials/archives-year.html.twig as partials/archive.html.twig file in the Typhoon-based theme you are using.

You will still need to modify the date_display_format: 'Y' though.

prikle commented 2 months ago

Hi rhuskster

Thanks for the quick reply!

I updated the addon to 2.0.3 and it works, but the tiwg still generates a menu with months and years. Look at the screenshot, but the links behind it are on the OK.

For Exampel: The Link "January 2024" linkt to ../archives_year:2024 grafik

rhukster commented 2 months ago

If you read my instructions you still need to change the date_display_format

prikle commented 2 months ago

Yes, I have done that. Is it possible that the settings in the Admin Panel overwrite this? grafik

I have also tried to create an additional option in the blueprint file and then activate it. This created the menu correctly, but the links all point to "../archives_year:1970".

rhukster commented 2 months ago

Yes set in the admin if you use that. My examples show the CLI way but your admin still shows month_year format, so it’s not changed. On May 16, 2024 at 09:44 +0100, prikle @.***>, wrote:

Yes, I have done that. Is it possible that the settings in the Admin Panel overwrite this? grafik.png (view on web) I have also tried to create an additional option in the blueprint file and then activate it. This created the menu correctly, but the links all point to "../archives_year:1970". — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

prikle commented 2 months ago

That was also just an attempt that I cancelled.

If I follow your instructions exactly, I have the behaviour described above. The links are created correctly but the menu still creates a list with month and year.

prikle commented 2 months ago

That was also just an attempt that I cancelled.If I follow your instructions exactly, I have the behaviour described above. The links are created correctly but the menu still creates a list with month and year.Am 16.05.2024 um 10:48 schrieb Andy Miller @.***>: Yes set in the admin if you use that. My examples show the CLI way but your admin still shows month_year format, so it’s not changed.

On May 16, 2024 at 09:44 +0100, prikle @.***>, wrote:

Yes, I have done that.

Is it possible that the settings in the Admin Panel overwrite this?

grafik.png (view on web)

I have also tried to create an additional option in the blueprint file and then activate it. This created the menu correctly, but the links all point to "../archives_year:1970".

Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you modified the open/close state.Message ID: @.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

rhukster commented 2 months ago

Apologies, it seems the blueprint file that defines the valid date formats was missing the 'year' / 'Y' option. That's been updated and 2.0.3.1 is released.. should show up in 10 mins or so.

prikle commented 2 months ago

Thanks for the customisation.

This is exactly the situation I have already tested. If you customise it, the list in the menu or in the sidebar is created correctly but the links all point to "../archives_year:1970".

grafik

Each link points to "../archives_year:1970", including 2017 and the following years.

rhukster commented 2 months ago

archives_year is the default taxonomy, you can change it here:

CleanShot 2024-05-16 at 13 10 59@2x

prikle commented 2 months ago

I have the setting as in your picture. If you set it up exactly as in your picture, you will have the list with month and year. (January 2015)

If you now also set the ‘Date Format’ to 2024. (You have delivered this setting with 3.0.2.1 in the blueprint) The list will only output correctly with the year. (2015, 2016, 2017, ...) But the links in the list all link to 1970.

grafik

331195624-6f77ccfe-11d9-423b-90ad-c5131ac70375

prikle commented 2 months ago

The date filter is not working properly. I have adjusted the code. It works now.

archives-year.html.twig

<ul class="archives">
{% for year,items in archives_data %}
    <li>
        <a href="{{ archives_url ?? base_url }}/{{ config.plugins.archives.taxonomy_names.year }}{{ config.system.param_sep }}{{ year|lower|e('url') }}">
        {% if archives_show_count %}
        <span class="label">{{ items|length }}</span>
        {% endif %}
        <span class="archive_date">{{ year }} </span>
        </a>
    </li>
{% endfor %}
</ul>