Provide more "data selectors" for machine names

Events happening in the community are now at Drupal community events on www.drupal.org.
dwangba's picture

First of all thanks a lot for all the hard work on this awesome module to everybody who contributed to it.

I am trying to do the following : create a new vocabulary every time a specific content type is created.

So I set up this rule :

Event : After saving new content

Condition : Content is of type

Action : this is when the problem occurs!
I choose "create a new entity"->"taxonomy vocabulary". To fill the value field I get a lot of possibilities through the data selector widget (or tokens) but for the machine name field I get only a few including "node:type" which I choose.

It works just fine the first time, but then the machine name is the same and it triggers an error. Question is : is it possible to use a unique machine name for the vocabulary created (for instance voc_node:nid)

I don't know if this is a feature request, a bug report or just my incompetence so I post this here.

AttachmentSize
Capture.png53.65 KB

Comments

Vocabulary or term?

itangalo's picture

Do you actually mean to create a new vocabulary?
It seems to me that you either want to create a new vocabulary every time a new content type is created, or a new term every time a new content node is created.

I haven't seen the effect you're experiencing, but I guess it can be explained if Rules recognizes machine names as a separate data type and only accepts data selection that is a machine name. You could probably work around it by using direct input and using standard replacement patterns (such as "[node:type]_[node:nid]").

I have a feeling that you want to use this for creating menus or something, using taxonomy terms, and that there are much easier (and less hacky) solutions for doing this. What is your use case?

//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 190+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!

Thanks Johan for your answer

dwangba's picture

Thanks Johan for your answer (and for your great screencast series) and sorry I wasn't clear enough.

Here is my use case :
I want to create groups using your solution (http://nodeone.se/blogg/johan-falk/alternative-solution-to-organic-groups) and I want group creators to be able to manage their own vocabulary for this group. So, whenever a node of the group content type is created, I want to create a vocabulary and assign it to the group (kind of http://drupal.org/project/og_vocab)

Using direct input and standard replacement patterns triggers this error :
"Value may only contain lowercase letters, numbers, and underscores and has to start with a letter.", so I think tokens or just not evaluated in the machine name.

Using a PHP Filter with the

dwangba's picture

Using a PHP Filter with the following code doesn't work neither. The resulting machine name is "voc_"
return $a = "voc_" . $node->nid;
I just posted in the Rules issue queue as well as I really need a solution to this one...

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: