I have a view with 144 elements without pagination. I want to display the result in my TWIG template. If I use the following code, the result is always 10.

I tested in several view and the result does not go beyond 10 :

{{ drupal_view_result('profil_page_contenu', 'block_2')|length }}

Comments

zenimagine created an issue. See original summary.

chi’s picture

This might be a cache issue.

Try
{{ dd(drupal_view_result('profil_page_contenu', 'block_2'))) }}

Also drush ev "echo count(views_get_view_result('profil_page_contenu', 'block_2'));"

zenimagine’s picture

@Chi This is what the page displays :

array:10 [▼
  0 => ResultRow {#17235 ▶}
  1 => ResultRow {#17255 ▶}
  2 => ResultRow {#17262 ▶}
  3 => ResultRow {#17269 ▶}
  4 => ResultRow {#17276 ▶}
  5 => ResultRow {#17283 ▶}
  6 => ResultRow {#17290 ▶}
  7 => ResultRow {#17297 ▶}
  8 => ResultRow {#17304 ▶}
  9 => ResultRow {#17311 ▶}
]
zenimagine’s picture

@Chi do you know why he stops at 10 ?

chi’s picture

drupal_view_result is just a wrapper around views_get_view_result. Did you try to count results with that function?

zenimagine’s picture

@Chi I do not know how to do this

chi’s picture

You can run Drush command I posted in #2.

zenimagine’s picture

@Chi It shows 10 in the terminal

chi’s picture

It shows 10 in the terminal

That means your issue is not related to Twig.

zenimagine’s picture

@Chi It's very weird because there is no pagination you all my sight blocks to 10. What can it come from ?

chi’s picture

I have no idea. Custom hooks, third party modules, patches whatever. You need to turn them off one by one to isolate the problem.

zenimagine’s picture

ok thank you

zenimagine’s picture

@Chi Hi I just did some tests and the problem only appears when it is a view based on a search index.

I'm using Search API 1.14 and Search API Solr 3.7

zenimagine’s picture

@Chi Is this a problem for Twig Tweak or Search API or Solr ?

chi’s picture

If drush ev "echo count(views_get_view_result('profil_page_contenu', 'block_2'));" returns wrong results then it's not Twig Tweak issue.

chi’s picture

Status: Active » Closed (outdated)