Hi everybody!

I need to set the title of a node from other fields provided
by a custom module created by me.

The custom module has two fields called number and name.

How do I set the node title to be 'number . name' ?

thank you.

Fabio

Comments

CnnmnSchnpps’s picture

... actually set the title field (which will be stored in the database), or just to display it in nodes?

to set the title of the current page, you can use drupal_set_title

for actually storing it in the databse, take a look at hook_validate

fax8’s picture

I need to store the created title in the node table.

hook_validate was ok for drupal 4.6 but I heard that in 4.7 changing
node field in the validate hook is forbidden.

then I tryed to use hook_execute writing something like:

function mynode_execute(&$node) {
$node->title = $node->fieldA . $node->fieldB;
}

but I was not luky with this.

marcp’s picture

change mynode_execute to mynode_submit and you should be okay to go. hook_execute doesn't exist (but it seems that it must have for a short amount of time).

-------
http://www.funnymonkey.com
Tools for Teachers

fax8’s picture

perfect...
Thank you marcp! I solved my problem!

Thank you!

fax8’s picture

I used hook_execute becouse of the documentation of
http://cvs.drupal.org/viewcvs/drupal/contributions/docs/developer/hooks/...

were it's reported as a valid hook.

I don't know if it's an error on documentation or else

fax8’s picture

As for
http://drupal.org/node/39576
hook execute doesn't exist enymore.

I will do a documentation issue report for this.

Fabio