Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit tag list #24

Open
metbril opened this issue Aug 27, 2018 · 5 comments
Open

Limit tag list #24

metbril opened this issue Aug 27, 2018 · 5 comments

Comments

@metbril
Copy link

metbril commented Aug 27, 2018

I have a long list of tags, that is shown in the sidebar in full. Therefor I suggest the following features:

Limit number of tags

Add a config parameter limit:.
Type is number.
Default is 0.
If limit is 0 all tags will be shown.

The parameter specifies how many tags will be included from the top of the list, assuming that the list is sorted descending by the number of times a tag is used. Basically the 'top x' items.

Threshold for count

Add a config parameter treshold:.
Type is number.
Default is 0.
If treshold is 0 or 1, then all tags will be shown.

The parameter specifies how many times a tag should have been used before it appears in the list. If, for example, treshold is 3, then only tags that are used at least 3 times will be shown.

@ghost
Copy link

ghost commented Aug 31, 2018

When I noticed you have the same problem I had, I thought I would got the chance to slightly contribute to this project and help the community. So here I am.
I patched the plugin with some tiny changing of the yaml files and the template.
I don't know if devs will accept my pull request, but it seems to work pretty fine.
If you want, you can find my solution in pull requests.

@metbril
Copy link
Author

metbril commented Aug 31, 2018

Thanks. I will try this asap.

The PR #25 only implements half of my request, but it's a good start.

Still missing: the threshold.

@metbril
Copy link
Author

metbril commented Aug 31, 2018

There are actually 2 possible scenarios to achieve this:

  1. Build a limited list (in the build() method
  2. Limit the output in the .twig template

The latter is probably easier to achieve and makes is possible to use different limits (or none at all) in other places in the site.

My assumption is, that adding code to a twig template that can (if needed) be called with parameters limit and/or threshold will be the best implementation.

It would be nice if this is included in the plugin, but I guess this can also be done in a custom template.

@metbril
Copy link
Author

metbril commented Aug 31, 2018

This is what I'm using currently

{# Customized from taxonomylist plugin #}

{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags() : taxonomylist.get() %}

{% set limit = 20 %} {# show only the first x items #}
{% set treshold = 3 %} {# at least this number of times used #}

{% if taxlist %}
<span class="tags">
	{% set i = 0 %}
    {% for tax,value in taxlist[taxonomy] if (((limit is not defined) or (i < limit)) and (treshold is not defined or (value >= treshold))) %}
        {% set active = uri.param(taxonomy) == tax? 'active' : '' %}
        <a class="{{ active }}" href="{{ base_url }}/{{ taxonomy }}{{ config.system.param_sep }}{{ tax }}">{{ tax }} ({{ value }})</a>
        {% set i = i + 1 %}
    {% endfor %}
</span>
{% endif %}

@simogeo
Copy link

simogeo commented Jun 22, 2022

same issue here. For example here : https://www.intermezzo-coop.eu/fr/actualites/tag:Chandigarh

Only 5 news are listed but it should be more ! Any help most welcome. Thanks

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

No branches or pull requests

2 participants