Check if term exists and create a node with rules

邮差的信 提交于 2019-12-02 10:08:32

问题


I actually have 2 questions regarding Drupal 7 and Rules.:

  1. How to check if a term exists with rules
  2. How to make a new node and forward to the node entry with rules

Let me sketch the scenario first and then explain in more detail:

Im currently creating a simple stock program to be used with a barcode scanner. The barcodes are stored in a taxonomy tree. I have 2 content types, a scan and a product.

A user is always presented with the scan content type (one big text input) that the barcode scanner will fill in and submit.

Drupal then checks to see if the scanned barcode is present in the taxonomy.

If it is not it creates a new node for product and lets the user fill in all the details about this barcode. If the term does exist, only the scan node is saved (which has a counter +1 or -1) so that I can later use views to see how many products went in or out.

Im trying to do this with rules...without success.


So my first question is: How can I check if a term already exists in a vocabulary? I think it needs to be done with a drupal native function in a php rule, but cannot find this function. Am I missing something?

My second question is about Rules entities.

I'm trying to create a node with a rule. When a term does not exist, rules needs to create a new product node and show it to the user so that they can fill in some detail fields and then save it.

I'm trying to do this with Rules -> Create new entity. As "Entity type" I choose "Node" and as "Content type" I choose my product content type. Then I also need to fill in a title. There is where it goes wrong. I tried to put every type of data or string inside this Value field of Title and Rules accepts it and saves the rule. But every time the rules failes creating the node with the following error message:

Unable to create entity node": Invalid data value given. Be sure it matches the required data type and format.

How can I effectively create a new node of a certain content type and present it to the user for further finishing, all with rules?

I hope I could explain it clearly :)

Thank you :)

来源:https://stackoverflow.com/questions/7756860/check-if-term-exists-and-create-a-node-with-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!