Patterns can include subpatterns. This is a partially experimental feature, and under certain circumstances users must take care of avoiding infinite recursion of included patterns.

From the LAB page of the patterns menu is possible to combine multiple together with one of the following options for inclusion:

  • All the sections (info and modules included) of the pattern
  • Actions only (info and modules sections excluded) of the pattern
  • The unique name of the pattern
  • The numerical id of the pattern

Notice that, including the pattern by reference (name or id), may limit its portability. On the other hand, it allows to write polimorphic patterns.

Execution mode for sub-patterns

The following options are available for sub-patterns execution:

  • Never run
  • Only during the first run
  • Only if pattern was updated
  • If it is the first run or if the pattern was updated
  • Only if the pattern code is attached (no lookup to database)
  • Always

Example

---
info:
  title: Example of included patterns
  category: General
  description: No description
  version: 1.0
  core: x.y
  author: root
  author_email: me@i.org
  author_website: localhost

lab:
  - 
    include:
      pattern:
        info:
          title: Create a menu
          description: Based on http://drupal.org/node/408952
          author: QScience
          category: Menu
          version: 1.0
          core: 7.x
          author_email: me@i.org
          author_website: qlectives.eu
        actions:
          - 
            create:
              tag: menu
              name: footer-links
              title: Footer Links
              description: Menu description.
  - 
    include:
      pattern:
        info:
          title: 'Taxonomy Vocabulary ADD -- working'
          description: Adds a vocabulary
          author: QScience
          category: Taxonomy
          version: 1.0
          core: 7.x
          author_email: me@i.org
          author_website: http://qlectives.eu/
        actions:
          - 
            create:
              tag: vocabulary
              name: Another Vocabulary
              machine_name: anothervoc
              description: Another Vocabulary, useless
              hierarchy: 0
  - 
    include:
      pattern:
        info:
          title: Toolbarrole (modify)
          description: >
            deside what kind of users (roles) can
            see the toolbar.
          author: QScience
          category: Toolbar
          version: 1.0
          core: 7.x
          author_email: me@i.org
          author_website: http://qlectives.eu/
        actions:
          - 
            modify:
              tag: toolbarrole
              addroles:
                - anonymous user
              delroles:
  - 
    include:
      pattern:
        info:
          title: edit the shortcut set name(modify)
          description: >
            change the shortcut set old name to new
            name
          author: QScience
          category: Shortcut
          version: 1.0
          core: 7.x
          author_email: me@i.org
          author_website: http://qlectives.eu/
        actions:
          - 
            modify:
              tag: shortcut_set
              oldname: new_set_fortest
              newname: newer_set_fortest

# Patterns exported: 4
# Date and time: Tue, 24 Apr 2012 15:06:02 +0200