How can i change the title of node creation form for a custom CCK type.
By default it says,

"Create MyCustomCCKNode"

I would like it to appear as

"Add MyCustomCCKNode"

Please let me know a simple way of doing this.

Thank you.

Comments

justageek’s picture

I think you need to create a module with a function similar to this:

function mycontenttype_form_alter(&$form, &$form_state, $form_id) {    
    if ('mycontenttype_node_form' == $form_id)
    {
           drupal_set_title(t('Add Whatever Your Content Type is Called'));
    }
  
    return $form;
}
fletch11’s picture

this isn't working for me. Has anyone had success with this?

geerlingguy’s picture

You need to also do a couple other slight modifications to this snippet in order to get it to work properly...

I made a custom module (named idcards), with a .info and .module file. Inside the .module file I pasted this code after the opening <?php tag (without the opening/closing php tags below):

/**
 * Implementation of hook_form_alter()
 */
function idcards_form_alter(&$form, &$form_state, $form_id) {    
    if ('id_card_node_form' == $form_id) {
    	// Change title of ID Card add page
    	drupal_set_title(t('Apply for an ID Card'));
    }
    return $form;
}

You need to change the word before _form_alter to your module's name, or to your theme's name if placing this snippet inside template.php. Then you need to change the value inside the if ('nameof_node_form' == statement to the content type name on which you want to have the page title changed (in my case, the content type was id_card).

__________________
Personal site: www.jeffgeerling.com

jimmyjames007’s picture

Thanks geerlingguy!

I was able to get this function to work using it within a new .module after I was unsuccessful with it in template.php.

francewhoa’s picture

Loving back your Drupal community result in multiple benefits for you  
mattcasey’s picture

page_title will only change the title of nodes, not the administration pages.. geerlingguy's solution worked for me - thanks!

- Matt

pubudusj’s picture

Hi all,

The function drupal_set_title('Some Title') works fine when form loads.

However when I submit the form and if there are any validation errors, the title not remain change into "Some Title".

What is the wrong there?

Thanks

jaypan’s picture

Install the Stringoverrides module, and 'translate' this: Create !type

to this:

Add !type

Contact me to contract me for D7 -> D10/11 migrations.

docans’s picture

I tried string override but it did not work so i just create a node template with the name (page-node-add-nodetype.tpl.php) and i went inside and changed the header title print $head_title; and the title output print $title; to the name i wanted to use and voila0.

dcarr’s picture

This worked great for me. Created a custom module name Form Titles and it worked. Thanks!

DrupalDan’s picture

@Dan, I tried to do the same thing but it didn't work. To be specific, I created a content type named "test" and to remove the word "create" I created a template file named "page-node-add-test.tpl.php" based on the default "node.tpl" and I changed the
print $title;

to
print test;

I didn't find the $head_title in the node.tpl. Could you please tell me if I miss anything?

Thanks