hello,

how to change a node's title after he was created by auto_nodetitle ?

regards,

Comments

kevinquillen’s picture

+1. In my case, Automatic Nodetitles controls content profile node type titles, based on first and last name. If someone changes those fields, the title does not update.

LeMale’s picture

no one can answer this ?

kevinquillen’s picture

It should work here:


/**
 * Implementation of hook_nodeapi().
 */
function auto_nodetitle_nodeapi(&$node, $op) {
  if ($op == 'presave' && auto_nodetitle_is_needed($node)) {
    auto_nodetitle_set_title($node);
  }
}

Or does presave not work as good as insert or update?

kevinquillen’s picture

Does anyone have a fix here?

pabloid’s picture

subscribe

vm’s picture

Component: User interface » Documentation
Assigned: LeMale » Unassigned
Priority: Critical » Normal

administer -> content

use the drop down to update node titles IIRC

running cron.php may also take care of this based on my minimal tests.

kevinquillen’s picture

This does not work for sites using Content Profile and a user updates their profile, and that node title is based on first + last name, for example. They won't have access to that. It needs to happen when they save the node.

vm’s picture

Status: Active » Closed (duplicate)

There are other issues explaining why it doesn't work on node save, not just for content profile but upon node save for any content type.

Marking this issue as a duplicate of:
http://drupal.org/node/1130694
http://drupal.org/node/1022714
http://drupal.org/node/1046666
http://drupal.org/node/373978 which includes a possible solution using rules.module found here: http://drupal.org/node/373978

granted the other issues are using different tokens than those mentioned in this issue but the resulting issue is the same. There are other more, descriptive issues and forum threads. Some indicate that because the title is the first field it's already saved before you get to the fields below it. Some more research would be required and legwork needed I'd think.

Following up in one of the issues filed previous to this one may aid.

I have cron run regularly with a cron job which seems to correctly change and save the tokens in the node title albeit not during the saving of the node itself. Perhaps using some php code as the project page states "Advanced users can also provide some PHP code, that is used for automatically generating an appropriate title." ? I've never tried to combat the issue in that way though.

Good luck.

kevinquillen’s picture


case 'update':
			if ($node->type == 'profile') {
				$node->title = auto_nodetitle_set_title($node);
			}
			
			break;

I got around it with my own hook_nodeapi- this worked for me, YMMV.

I think this might not be necessary if this function is changed:


function auto_nodetitle_is_needed($node) {
  return empty($node->auto_nodetitle_applied) && ($setting = auto_nodetitle_get_setting($node->type)) && !($setting == AUTO_NODETITLE_OPTIONAL && !empty($node->title));
}

By removing !empty($node->title) check, my update case is no longer needed in the hook_nodeapi of my custom function.