-
Notifications
You must be signed in to change notification settings - Fork 14
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
Limited tag list #25
base: develop
Are you sure you want to change the base?
Limited tag list #25
Conversation
Add limit variable
Insert limit variable
Loop that limit the displaying of tags
Now that the number of settings is increasing, it might be wise to also add i18n through a languages.yaml. |
Looking at the twig, it actually also changes the class names and not only the logic, so this would not only change the number of displayed tags, but also how they are displayed. For me, this PR should ONLY change the logic itself |
<a class="{{ active }}" href="{{ base_url }}/{{ taxonomy }}{{ config.system.param_sep }}{{ tax }}">{{ tax }}</a> | ||
{% set count = 0 %} | ||
{% for tax,value in taxlist[taxonomy] if count < limit %} | ||
{% set label_class = uri.param(taxonomy) == tax ? 'label-primary' : 'label-secondary' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also changes class names. Not only the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't touch anything, just add a condition in the loop which refers to a variable in the taxonomy.yaml, because I noticed that the plugin already put the tags in order from the most used one to the less used ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the {% set active
line has been removed, and you have introduced label-primary
and label-secondary
to the code. Your contribution is probably not originating from the plugin itself, but from a customized (themed?) twig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I forgot about my old modifications before posting the code.
I have to admit it: that's my first time posting something on github.
I'll amend the lines soon.
{% set active = uri.param(taxonomy) == tax? 'active' : '' %} | ||
<a class="{{ active }}" href="{{ base_url }}/{{ taxonomy }}{{ config.system.param_sep }}{{ tax }}">{{ tax }}</a> | ||
{% set count = 0 %} | ||
{% for tax,value in taxlist[taxonomy] if count < limit %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count < limit
could cause issues if you have no limit value. need to also check if limit is set before this if is evaluated
|
||
{% if taxlist %} | ||
<span class="tags"> | ||
{% for tax,value in taxlist[taxonomy] %} | ||
{% set active = uri.param(taxonomy) == tax? 'active' : '' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also does need this active state put back.
I suggest to consent users to limit the tag printed on the screen, following the priority given by use frequency of tags.