Add fields or groups to multiple content types

michaek - February 16, 2009 - 21:07
Project:Patterns
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Issue tags:patterns, token
Description

Thanks for all the work that went into this module. It's just great.

I'm hoping there's a way to configure a CCK field or group to be used in multiple content types (or define some kind of inheritance for content types...). I haven't dug enough into the source to know whether that's possible - I'm doing that now - but I'm hoping someone will tell me if it is, and save me a little (more) legwork.

Thanks again!

#1

michaek - February 16, 2009 - 22:16

Looks like that could be messy, after some inspection. I'll just duplicate the declarations in the XML for now, but I'm hopeful that there'll be a way forward to share configuration across content types.

#2

ChrisBryant - February 24, 2009 - 08:38

That was our hope and plan as well when including Token module support, though it's not all the way there yet. For example it supports something like this (in YAML format since it's now supported and it rocks!)

actions:
- tag: role
value: administrator
- tag: form
form_id: adminrole_admin_settings
adminrole_adminrole: @1@

Here the @1@ is the value from the first action which you could place anywhere else in the pattern. @2@ would replace the value from the second action and so forth.

Obviously this isn't perfect since you might change the order of items in the pattern and then you have renumber the rest of the places it's used. We've talked about having definitions as well so the numbering wouldn't be an issue, but it doesn't currently support that.

#3

sarvab - February 24, 2009 - 08:39

The patch you submitted here looks like it would take care of this?

Thanks for the appreciation! We've been working pretty hard on it and have a good number of new and exciting things planned :)

#4

ChrisBryant - February 24, 2009 - 08:40

adding tags.

#5

vaish - February 24, 2009 - 09:42

Actually, token support just got updated yesterday. Now it's possible to assign labels to the actions, and refer to those labels later on within the pattern or even its sub-patterns. That eliminates the problem with breaking your pattern every time you reorder, add or delete new actions.

This is how example from #2 would look like now:

  - tag: role
      action_label: adminrole
      value: administrator
  - tag: form
      form_id: adminrole_admin_settings
      adminrole_adminrole: @adminrole@

#6

vaish - February 24, 2009 - 11:04

I just realized that this feature is not really documented so I thought I might explain it a little bit.

Patterns are using something called identifiers. Each action returns identifier after successful execution. Normally that is the unique ID of the item that was created by the action. E.g. menu_item action will return mlid, node action will return nid, etc. Those identifiers are available to all subsequent actions.

Example:

  - tag: node
      action_label: aboutus
      type: page
      title: About Us
      body: lorem ipsum...
  - tag: menu_item
      menu: Primary Links
      title: About Us
      path: node/@aboutus@
      weight: 5

Above pattern will create one node with the title "About Us". If we want to create menu item for this page, we need to know its nid in order to create valid path. This is where identifiers are used.
First we label node action so that we can refer to it later on. Then while defining the path for menu item we use that label to refer to nid of the About Us page.

Many times identifiers are not required because unique IDs for many actions are already known. For example ID for content action is "type" which is defined within the action itself and known at the time of writing the pattern.

It's also worth mentioning that currently not all the components have support for identifiers implemented. As a result, corresponding actions will not return an identifier.

 
 

Drupal is a registered trademark of Dries Buytaert.