Problem/Motivation
While working on #3583128: Views DOM ID class is missing for Ajax-enabled views, we discussed about adding a new ViewTemplateSource for slots
PageLayout already has PageLayoutSource which is rendering page.html.twig and is automatic injected with the existing block layout configuration by BuilderDataConverter
If we add something like that for Views, we can:
- initialize each View display managed by Display Builder with the exact same look at the same display without Display Builder (if there is specific CSS template(s) in themes, they are still rendered, and
viewtheme hook preprocesses are still executed) - allow builders to remove the node from the tree if they don't want it, and go the full display builder way
Proposed resolution
Add modules/display_builder_views/src/Plugin/UiPatterns/Source/ViewTemplateSource.php:
- for view context
- not configurable
- with slots:
title,header,exposed,attachment_before,rows,empty,pager,attachment_after,more,footerandfeed_icons - rendering
#theme => 'view'or#type => 'view'
Replace default_view.yml fixtures by a BuilderDataConverter service which build the tree according to the current display configuration.
Other task
A good opportunity to review and cover display_builder_views/src/Hook/PreprocessViewsView.php.
Issue fork display_builder-3591025
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pdureau commentedI have started playing around. I hope it can help someone willing to take the task.
It is important than the
'#theme' => 'views_view'returned by::getPropValue()is loading the expected template suggestions:views-view--{view-name}--{display-id}.html.twigthis was not tested and we may need a specificViewTemplateSourceTestNo need to replace
default_view.ymlfixtures by a BuilderDataConverter service, just adding some information to the fixture may be enough.Comment #5
mogtofu33 commentedComment #6
mogtofu33 commentedComment #7
mogtofu33 commentedProblem I think with this approach is we now have views regions fixed when giving Views options (ajax/class) available to the rendered view.
But we want mostly to provide: Display builder managed fully - Views ajax and class from UI working.
Comment #8
pdureau commentedInitial proposal
This ticket was initially authored to address this situation:
views-view--{view-name}--{display-id}.html.twigand sometimes other view templates and related preprocesses)With a
ViewTemplateSourceand the corresponding change infixtures/default_view.yml:views-view.html.twig, without needing the preprocess anymore.Current proposal
The current state of the MR is now targeting something different: always print the wrapping attributes additions and alterations from
#[Hook('preprocess_views_view')](changed inviews-view.html.twig).Am I understanding right?
However:
ViewTemplateSource, those attributes will be rendered twiceMoreover, with the changes in
fixtures/default_view.yml, theViewTemplateSourceplugin seems to be useless now, because it is not shown in the libraries (until we decide to extend component library to all plugins implementingSourceWithSlotsInterface, but that will be another ticket). Am I missing something?So, it seems we are in-between two different strategy here, and we need to decide:
(Footnote:
ViewTemplateSourceplugin doesn't have contexts and is loading the view from settings, it is "normal" until we switch to a proper context system in #3542796: Preview of view sources)Comment #9
pdureau commentedFollowing today weekly, we are splitting the work:
ViewTemplateSource, but postponed as a nice-to-have for 1.0.0 scope.Comment #10
mogtofu33 commentedFixed with #3583128: Views DOM ID class is missing for Ajax-enabled views.