Changing the Node header in Drupal?

Let's say I have a node called "product". When I create a node like this, it will always display: "Create Product" as the node name. How do I change this heading WHEN CREATING NODE?

+2


source to share


7 replies


do you mean you have a "product" content type ?

the "Create Product" header when creating a node of type "product" is set to node_add($type)

:

// ...
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));
$output = drupal_get_form($type .'_node_form', $node);
// ...

      



there are at least 2 options to change this:

+6


source


This should do the trick in your custom module, just specify the content type.



 function your_module_form_alter(&$form, $form_state, $form_id) {
      if ($form_id == 'contenttype_node_form') {
        drupal_set_title(t("Title you prefer"));
      }
    }

      

+5


source


Try if none of the above works:

function YOUR-THEME_process_page(&$variables) {
  if (arg(0) == 'node' && arg(1) == 'add') {
    switch(arg(2)) {
      case 'YOUR-CONTENT-TYPE':
       $variables['title'] = t('New Record');
    }
  }
}

      

+2


source


try it

yourmodule_form_product_node_form_alter(&$form, $form_state)
{
  drupal_set_title($foobar);
}

      

+1


source


I am assuming that you want you to change the words "Create Product"

For a quick and easy solution, you can use the [string override] [1] module. It's a bit hacky, but it's simple and has a nice interface to change it - there is something to be said for simplicity :-)

[1]: http://drupal.org/project/stringoverrides string overrides

+1


source


I have implemented a module that solves this problem. Check Node Add Header .

Hope it helps.

+1


source


try it,

function hook_node_view($node, $view_mode, $langcode) { 
  if (arg(0) == 'node') {
  $nid = arg(1);
  .
  .
  .
  .
  drupal_set_title($title);
}  

      

}

Works.

Thank you, Latika S.

0


source







All Articles