Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Documentation for the Patterns Views syntax is coming soon... for the time being refer to this example view action below.
Valid properties for "view" action
Coming soon...
YAML Example:
-
tag: view
action: update
details:
name: view_test
description: This is a test view
tag: test
base: node
display:
- name: default
section:
- name: row_plugin
value: node
- name: row_options
value:
teaser: 0
links: 1
comments: 1
- name: use_pager
value: 1
data:
pager_element: 2
- name: items_per_page
value: 25
- name: title
value: Test
- name: empty
value: There are currently no posts to display.
item:
- type: filter
name: node.type
data:
operator: in
value:
page: page
- type: filter
name: node.status
data:
operator: =
value: 1
- type: sort
name: node.created
data:
order: DESC
granularity: minute
- name: page
section:
- name: path
value: test
- name: block
section:
- name: items_per_page
value: 5
XML Example:
<view>
<!--
The action element lets you specify the type of action you would like to perform on this view.
An insert action only works if the view does not exist while an update action will try and
create a view for you if it does not exist first (default). 'remove' will delete the view
-->
<action>update</action>
<!--
Core view information, name, description, tag, and base go inside details.
name and base are required for new views while either name or vid are required for existing views
-->
<details>
<name>view_test</name>
<description>This is a test view</description>
<tag>viewtag</tag>
<base>node</base>
</details>
<!--
Any action on a display must go inside a display element. Each display element must also
specify its ID via the name element. The default display will be used for the first display
that does not specify a name. You can set the 'action' element to 'delete' to specify a
display for deletion. The default action is 'update'
-->
<display>
<!--
Any change to values inside Basic Settings or Page/Block/etc settings go inside
a section element. There should be one section element per change. The simplest way
to specify changes is to provide the name and value elements. Sometimes a section
requires more information in which extra keys can go inside a 'data' element.
-->
<section>
<name>display_title</name>
<value>Default Display</value>
</section>
<section>
<name>title</name>
<value>View Edits</value>
</section>
<section>
<name>style_plugin</name>
<value>grid</value>
</section>
<section>
<name>style_options</name>
<value>
<columns>3</columns>
<alignment>horizontal</alignment>
</value>
</section>
<section>
<name>row_plugin</name>
<value>node</value>
</section>
<section>
<name>use_ajax</name>
<value>1</value>
</section>
<section>
<name>use_pager</name>
<value>1</value>
<values>
<pager_element>2</pager_element>
</values>
</section>
<section>
<name>items_per_page</name>
<value>15</value>
<values>
<offset>3</offset>
</values>
</section>
<section>
<name>use_more</name>
<value>1</value>
</section>
<section>
<name>distinct</name>
<value>1</value>
</section>
<section>
<name>access</name>
<value>
<type>role</type>
</value>
</section>
<section>
<name>access_options</name>
<value>
<type>role</type>
<role>1</role>
<role>2</role>
</value>
</section>
<section>
<name>exposed_block</name>
<value>1</value>
</section>
<section>
<name>header</name>
<value>This is the view header</value>
<values>
<header_empty>1</header_empty>
<header_format>2</header_format>
</values>
</section>
<!--
Adding/configuring filters/sorts/fields/arguments/relationships is handled by the
item element. The type and name fields are required. An action element can be
used to 'remove' the item while the default action is 'update' ('insert' is available).
Any standard data configuration goes inside the 'data' element while extra data configurations
go inside an 'extra' element. Styling options go inside a 'style' element
-->
<item>
<type>relationship</type>
<name>comments.uid</name>
<data>
<label>User</label>
<required>1</required>
</data>
</item>
<item>
<type>argument</type>
<name>node.nid</name>
<data>
<title>%1</title>
<default_action>not found</default_action>
<default_argument_type>node</default_argument_type>
<validate_type>node</validate_type>
<validate_argument_node_type>
<page />
</validate_argument_node_type>
<validate_argument_nid_type>nids</validate_argument_nid_type>
<validate_fail>not found</validate_fail>
</data>
<style>
<count>1</count>
<items_per_page>15</items_per_page>
</style>
</item>
<item>
<type>sort</type>
<name>node.created</name>
<data>
<order>DESC</order>
<granularity>minute</granularity>
</data>
</item>
<item>
<type>filter</type>
<name>node.type</name>
<data>
<value>
<story />
</value>
<operator>in</operator>
</data>
</item>
</display>
<display>
<name>page</name>
<section>
<name>path</name>
<value>view/test</value>
</section>
</display>
</view>
Comments
Possible error in yaml example
We tried to import yaml using the example and some elements were not work well.
comparing with views_patters we have discovered a possible error.
Paste the possible example solution:
Great work
Karlos g liberal => http://www.investic.net/blog/karlos