How to update a node (book or page) before saving it without touching the module code in Drupal?

I would like to set some values ​​in node before writing data to the database. I am already working by modifying book_nodeapi, but I would like to do this from outside the code, some _alter options that will allow me to leave the module code untouched would be great.

thanks

+4
source share
2 answers

If I understand what you need, the Rules module can be very useful in such tasks. All you have to do is create a condition according to the type of content you want and have an action that sets the value. Setting a value can be done using static Token values ​​or even PHP code.

Here is a screencast with the basics of the rules.

+1
source

You can create your own module and implement hook_nodeapi ( mymodule_nodeapi ) in it, as a book module does. Each active module gets the ability to connect to nodeapi for all nodes.

+2
source

Source: https://habr.com/ru/post/1309890/


All Articles