Closed (fixed)
Project:
Twig Tweak
Version:
8.x-1.2
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Aug 2016 at 09:35 UTC
Updated:
6 Mar 2023 at 13:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
chi commentedThat is not possible with this approach. If you need to create some wrapper around the view I would suggest move it to view template.
Comment #3
chi commentedWell, there is a trick. If a view returns nothing ("empty result behavior" is not configured).
striptags and trim filters are needed in case the view returns empty markup with no content.
Comment #5
sgurlt commentedI had the same issue and sometimes the suggested solution did not work for me.
So I made myself some thoughts and created a patch for this.
With this patch applied, empty views are never getting printed out. The twig syntax has not changed, so we still can print out views with this:
{{ drupal_view('myView', 'myDisplay') }}Additional it is now possible to do stuff like this:
Cheers :)
Comment #6
chi commentedSome people would like to display "Empty result text" or "View attachment" when a view has no results. The patch #4 is not acceptable for them. Furthermore it breaks backward compatibility.
Closing this as the reporter was given an answer.
Comment #8
sgurlt commentedInteresting way to deal with someone who just wanted to help...
As mentioned your way did not work always so I think the feature request is still open.
In case of just rejecting my patch, it would be better to extend it and improve the module.
Comment #9
chi commented@sgurlt I appreciate any help but this patch is not acceptable for reasons explained in #6.
Comment #10
devkinetic commentedFor anyone landing here from a search engine, the pattern has changed.
https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/docs/views.md#c...