I am creating a module that that will create all the required types for the application. I also wan it to setup the automatic node titles with a set formula.

I have the basic install working fine... Custom_type_instal()...but The automatic title generation option is set to disabled. I see in the auto_node title they defined "AUTO_NODETITLE_ENABLED", but I am not sure how to use it.

I also need to select "Automatically generate the title and hide the title field" in the code and set the format "[node:field_custom_1], [node:field_custom_2]"

Any ideas? This is my first post to this forum. I have searched google and found nothing on this. I also didn't get much information from the auto_nodetitle module.

Comments

WorldFallz’s picture

You should be able to use hook_form_alter in your custom module to set those options as desired.

webbit’s picture

I see what you mean with http://websmiths.co/blog/very-introduction-drupals-hookformalter.
function custom_example_form_alter(&$form, &$form_state, $form_id){
// target a single form
if($form_id == "page_node_form"){
$form['title']['#title'] = t('New Form Title');
}
}

This will force a custom title in place, but that isn't exactly what I was looking for.

I would like to continue to use the auto_nodetitle module. I want to have it update the "automatic title generation" to "Automatically generate the title and hide the title field" and add a "pattern for the title" (for example "[node:author] , [node:nid]").

Is there any way to update this through the code? I don't even see which table is holding this information.

WorldFallz’s picture

You should be able to use hook_form_alter to manipulate the auto nodetitle fields directly (similar to what you've done above for the core title field). Your custom module will need to run after auto_nodetitle so you need to change the weight. Then you need to operate on the node settings form to get at those auto nodetitle settings.

webbit’s picture

This is the closest I could find.
http://ericlondon.com/posts/149-overriding-the-node-profile-form-and-aut...

// create a form_alter hook to remove the field from the form:
function MYMODULE_form_alter(&$form, $form_state, $form_id) {

  if ($form_id == 'profile_node_form') {
    // remove title from view
    $form['title']['#access'] = false;
  }
    
}

// create a nodeapi function to create the node title when the node is created
function MYMODULE_nodeapi(&$node, $op, $a3=NULL, $a4=NULL) {
  if ($node->type =='profile' && $op=='insert') {
    $node->title = $node->field_profile_name_first[0]['value'] . " " . $node->field_profile_name_last[0]['value'];
    node_save($node);       
  }
}

This looks like it will do the same thing, but Still doesn't show how to control auto_nodetitle.

What am I missing? How do I find out where all the arrays are located? I manually set an auto_nodetitle, but couldn't find where it saved it in the database.

Would it be something like this?

function MYMODULE_form_alter(&$form, $form_state, $form_id) {

$form['auto_nodetitle']['ant'][#options] = AUTO_NODETITLE_ENABLED;
$form['auto_nodetitle']['ant_pattern']['#disabled'] = TRUE;
$form['auto_nodetitle']['ant_pattern']['#title'] = node->field1 . ',' . node->field2;
}

WorldFallz’s picture

i'm not anywhere I can check atm, but yes it would be something like that. Get the devel module (if you don't have it already), and do a dpm($form); at the top of your form_alter-- that will show you the entire form. Somewhere in there should be the autonodetitle settings you want to modify.