Hi,
I just installed the module is it is really excellent. I created a view with two block display. The first block displays my content and the second one displays nothing, just a header with the following code :
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
<i class="fa fa-object-group fa-lg"></i> Ses contenus (<dd>{{ drupal_view('profil_page_contenu_utilisateur', 'block_1', '@total') }}</dd>)</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body"><dd>{{ drupal_view('profil_page_contenu_utilisateur', 'block_1') }}</dd></div>
</div>
</div>
</div>
With the following line of code :
<i class="fa fa-object-group fa-lg"></i> Ses contenus (<dd>{{ drupal_view('profil_page_contenu_utilisateur', 'block_1', '@total') }}</dd>)</a>
How to retrieve the element number of a view (block_1) ?

Comments
Comment #2
chi commentedI am not sure I understand the question correctly. Guess you need to add a hidden field to the view that would hold the element number. Views provides
counterfield type for this purpose.Comment #3
zenimagine commentedI created a view of my products. I added in the header of the view "Global: Result summary (Global: Result summary)" with the token "@total".
I created a second view and I want to display the product number of my first view in it.
I installed the https://www.drupal.org/project/twig_tweak module
I added a field "Configure field: Global: Custom text" to my second view, with
<dd>{{ drupal_view('boutique_page_produit', 'block_2') }}</dd>My first view is well displayed in it.What I am trying to do :
I do not want to display the first view in the second, I only want to display "Global: Result summary (Global: Result summary)" with the token "@total" in my second view.
How to do this ?
Comment #4
zenimagine commentedComment #5
chi commentedStill not sure I understand the question correctly. However you might not need Tweak tweak module for this task if you use aggregation option of the view. Another possible solution is using
drupal_view_result()Twig function.{{ drupal_view_result(view_id)|length }}Comment #6
zenimagine commentedComment #7
zenimagine commented@Chi
Watch the last 2 screenshots.
If I put the code:
<dd>{{ drupal_view('boutique_page_produit', 'block_2') }}</dd>view-2.png will show all my view-1.png (I only want the number of product)
Comment #8
chi commented#5 should work for you.
Comment #9
zenimagine commented@Chi
<dd>{{ drupal_view('boutique_page_produit', 'block_2') }}</dd>{{ drupal_view_result(view_id)|length }}thank you, taking my current code and your code is correct :
<dd>{{ drupal_view_result('boutique_page_produit', 'block_2')|length }}</dd>Comment #10
zenimagine commentedI confirm it works. Thank you
Comment #11
zenimagine commentedComment #12
chi commentedJust to be clear, you should not put
<dd/>tags to your snippet. They make not sense in this context.Comment #13
zenimagine commentedOn my view I use pagination. My problem :
If I have 4 pages with my view
{{ drupal_view_result('boutique_page_produit', 'block_2')|length }}displays the number of items in the page. I want the total slice number of the view (not just the page).
Comment #14
chi commentedI think you have to create another view without pagination.
Comment #15
zenimagine commentedOK, thanks