Is it possible for a module to define patterns?

jbrown - August 18, 2009 - 00:18
Project:Patterns
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

It would be really great if modules could exposes patterns that they come with directly, instead of having to be placed in one of the patterns directories.

Is this possible?

#1

ChrisBryant - August 18, 2009 - 06:02

This should already be possible by creating a folder called "patterns" inside your module folder and then adding your patterns there. It was added in the last month with the following commit/revision:

http://drupal.org/cvs?commit=242188
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/patterns/pa...

Please try that and confirm it's working as intended for you.

Cheers!

#2

ChrisBryant - August 18, 2009 - 06:14

I forgot to mention that a module can supply a pattern to be run when that module is installed: From the patterns.module file...

/**
* Execute default configuration for module during the module installation
*
* This function should be called by other modules from
* within their hook_enable() implementation.
* Module should also provide modulename.config file containing PHP array
* with the actions that need to be executed.
*
* @param $module
*   name of the module calling the function
*/

#3

sarvab - August 18, 2009 - 08:56

You can do this now, but recent changes make it require an extra step then what Chris posted above.

Basically you need to have your module implement hook_patterns_directory() and return the path to a directory that can contain either a /patterns directory, or a /components directory for use with the patterns module. So in you're module if you were to implement that hook and do: return drupal_get_path('module', 'mymodule'); it would look in /path/to/your/module/patterns for available patterns.

#4

jbrown - August 18, 2009 - 11:37
Category:feature request» support request
Status:active» closed

Thanks guys!

 
 

Drupal is a registered trademark of Dries Buytaert.