Active
Project:
Drupal core
Version:
main
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Oct 2016 at 17:54 UTC
Updated:
1 Jul 2020 at 18:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #4
lquessenberry commentedI found this nasty little bugger yesterday during my attempts to use the counter in a math expression with views. You will notice that I mention this in comment #20 on this thread:
https://www.drupal.org/project/ctools/issues/2544670#comment-12342418
In conversation with @rszrama I noticed that when you dump the counter in Twig, it shows up as a 13 length string. That's odd don't you all think?
So... about that counter. LOL It's hosed
I too have noticed
This is the counter dump.
string(13) "1"This is the NID dump.
object(Drupal\Core\Render\Markup)#1826 (1) { ["string":protected]=> string(3) "178" }This is the title dump.
object(Drupal\Core\Render\Markup)#1811 (1) { ["string":protected]=> string(78) "<a href="/nepiswutarechicafreuishafrowaswuchobrade" hreflang="en">Distineo</a>" }[3:55]
It thinks it's a 13 character string. :neutral_face:
Comment #5
gregorybesson commentedSee a possible solution there: https://www.drupal.org/project/drupal/issues/2764651#comment-12358994
Comment #7
joe huggansI figured a workaround for this, I used a custom text field in the view, excluded the counter from the view in the settings and used a token to show the counter in the custom text field.
Comment #8
psf_ commentedHi,
While I writing a pad twig filter to use in views count, with rewrite, I found that the string is always "{{ counter }}", 13 chars how lquessenberry say in #4.
The rewrite that I used are:
I think that views is using replacement patterns in twig before it has a value, but I can't found this in code.
Comment #9
ruhaim commentedI also have bumped into this issue, but how do we allow tokens #7 to work in this case
#7joeuk31?
Comment #10
joe huggansYou create a custom text field and then use a replacement pattern to show to counter value. Since the value now comes through the custom text field in the view it works. for some reason. You understand? If you don't let me know and I will try help. :0
Comment #11
handkerchief@joeuk31 not working for me :(
Comment #12
pixelpreview@gmail.com commentedthe workaround of @joeuk31 not working for me too
I have created a global text field and add the "count" token in the "rewrite result" field
in an other field I use the token from the global text field not directly the token of count field and it doesn't work :(
if I do :
{% if nothing == 1 %}
...
{% endif %}
your workaround don't work, it's the same result than call directly the counter token
{% if counter == 1 %}
...
{% endif %}
Can you explain precisely you solution ?
Comment #14
winniezz commentedcheck here https://www.drupal.org/project/drupal/issues/2764651#comment-12792086
This problem is more complicated than expected...
Comment #17
avpaderno