ui_patterns icon indicating copy to clipboard operation
ui_patterns copied to clipboard

Request: Views support for whole view (format)

Open bserem opened this issue 7 years ago • 6 comments

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

bserem avatar Sep 03 '17 10:09 bserem

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 ?

ademarco avatar Sep 23 '17 09:09 ademarco

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.

bserem avatar Sep 25 '17 12:09 bserem

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.

ademarco avatar Sep 26 '17 07:09 ademarco

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).

joshuaboltzmc avatar Jan 25 '18 19:01 joshuaboltzmc

Would be great to have deeper support/control for Views:

  1. Select component to render whole View (say, Accordion for list of nodes).
  2. 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.

tonystar avatar Jan 29 '18 17:01 tonystar

I wrote a custom views plugin style for that:

imagen

The settings

imagen

manuel-adan avatar Sep 30 '19 16:09 manuel-adan