ui_patterns
ui_patterns copied to clipboard
Request: Views support for whole view (format)
It would ideal to have support to style the whole view using UI patterns.
I know that we can use views for the row styling, which is pretty amazing. What I would like to see on top of that is the option to select patterns as the view format (alongside 'unformatted/html list', 'table' and 'grid').
I'll try to describe my thoughts giving an example, in order to make things easier to understand.
Lets say I have a pattern called card
with fields image, title, content, action
and a twig like:
<div class='card' style='background-image:url("{{ image }}")'>
<div class="card__body">
<h2 class="card__title">{{ title }}</h2>
<p class="card__content">{{ content }}</p>
<div class="card__actions">{{ actions }}</div>
</div>
</div>
This works fine as a row plugin with ui_patterns.
Now, I have an extra pattern, called cards
with one field, named card
and a twig file with something like the following:
<div id="cards" class="cards other-fancy-stuff">
{# VIEWS ROWS GET PRINTED HERE #}
</div>
This way, I can pre-style my views in ui_patterns, and then assign the pattern to the view and have the expected output (see: https://www.drupal.org/files/project-images/components_combo.png)
Do you believe something like that is possible? Does it make sense to anybody else?
Hope I explained it well
This is totally possible, it's about building yet another Views plugin (a display plugin in this case) that would use patterns to format the view.
BTW: since patterns are exposed as layouts too have you tried using something along the line of https://www.drupal.org/project/layout_plugin_views ?
I didn't knew about layout_plugin_views, but it seems pretty old for D8 standards.
Anyway, I am giving a try for a views plugin right right now.
Yep, have a look, if not then we can just add it to UI Patterns, it's totally in the scope of the core module.
FYI - since you'll probably hit these when installing layout_plugin_views (since it depends on layout_plugin), here is a layout_plugin patch: https://www.drupal.org/project/layout_plugin/issues/2871585
Error: Cannot use object of type Drupal\Core\Layout\LayoutDefinition as array in Drupal\layout_plugin\Plugin\Layout\LayoutPluginManager->getThemeImplementations() (line 162 of modules/contrib/layout_plugin/src/Plugin/Layout/LayoutPluginManager.php).
Would be great to have deeper support/control for Views:
- Select component to render whole View (say, Accordion for list of nodes).
- Define mapping on per-item basis (say, node title goes to Accordion pane header and node description goes to Accordion pane body).
This would require additional metadata in pattern definition (Accordion have panes, each pane have header and body) - kind of substructures.
I wrote a custom views plugin style for that:
The settings