Add views display overrides option.

cdale - May 4, 2009 - 10:44
Project:Patterns
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Can patterns manage this via the views tag? Or does a custom form tag option need to be set?

#1

cdale - May 4, 2009 - 12:42
Title:How to handle override options on views?» Add views display overrides option.
Component:Documentation» Code
Category:support request» feature request
Status:active» needs review

I've created a small patch which achieves this. My first attempt was trying to use the Form API to call the correct override action, then call the form again to save the value, but this proved difficult to get to work, so I've opted with just doing what the override submit handler does. It works well.

Example usage is as follows:

  -
    tag: view
    action: update
    details:
      name: test
      description: Test view
      tag: test
      base: node
    display:
      - name: default
        section:
          - section: title
            value: Test
          - section: row_plugin
            value: node
          - section: row_options
            value:
              relationship: none
              build_mode: teaser
              links: 1
              comments: 0
          - section: use_pager
            value: 1
        item:
          - type: filter
            name: node.type
            data:
              operator: in
              value:
                page: page
          - type: filter
            name: node.status
            data:
              operator: =
              value: 1
          - type: sort
            name: views.random
      - name: page
        section:
          - section: path
            value: random-path
          - section: menu
            value:
              type: normal
              title: Click me
              name: primary-links
      - name: block
        section:
          - section: items_per_page
            value: 2
            override: true                              <-- Override items_per_page on block to have a different value than the rest of the view displays.
          - section: use_pager
            value: 0
            override: true                              <-- Override use_pager on the block also.
          - section: block_description
            value: Testimonials

AttachmentSize
patterns-views-override-display.patch 915 bytes

#2

cdale - May 4, 2009 - 23:18

Oops. That example YAML needs to remove the second override option, as views overrides all those items together....

#3

cdale - May 5, 2009 - 04:48

I've change the patch, so that it now handles override options on the display settings, as well as the handlers. I've also added the ability to remove handlers as I couldn't see this done anywhere. There is also a bug fix for getting the correct display id on the item for update actions. Sorry for bundling this all together. I can break them out into separate patches if it is an issue.

This patch can be used with the following pattern to have a default and page view using a node.created sort handler, and a block using a views.random sort handler.

-
    tag: view
    action: update
    details:
      name: test
      description: The test view
      tag: test
      base: node
    display:
      - name: default
        section:
          - section: title
            value: Test
          - section: row_plugin
            value: node
          - section: row_options
            value:
              relationship: none
              build_mode: teaser
              links: 1
              comments: 0
          - section: use_pager
            value: 1
        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:
          - section: path
            value: test
          - section: menu
            value:
              type: normal
              title: Test
              name: primary-links
      - name: block
        section:
          - section: items_per_page
            value: 2
            override: true
          - section: use_pager
            value: 0
          - section: block_description
            value: Test
        item:
          - type: sort
            section: sorts
            override: true
          - type: sort
            name: node.created
            action: remove
          - type: sort
            name: views.random

#4

cdale - May 5, 2009 - 04:48

Forgot the patch

AttachmentSize
patterns-453026.patch 2.39 KB
 
 

Drupal is a registered trademark of Dries Buytaert.