1

I have created custom content type for upload the details. I have used hook_form_alter to set the node title as "Upload". When I edit the node in node/%/edit the title remains "Upload". I want the title to be "Edit" .How to do this?

1
  • Could you please paste your alter code? And I didn't get where you want the "Upload" title? you want this title to be seen just in create form? Jul 21 '15 at 7:57
4

Please try this:

function hook_form_alter(&$form, &$form_state, $form_id) {
   if($form_id == 'form-id') {
   if(arg(0) == 'node' && arg(2) == 'edit'){
     drupal_set_title('Upload Edit');
    }
    else{
     drupal_set_title('Upload'); }

  }
}
1
  • Which form ID would you check to be sure it's the node edit form being shown?
    – apaderno
    Jul 21 '15 at 12:28
0

After searching finally found the answer. Place this code in your template.php

if (!empty($variables['page']['content']['system_main']['#form_id']) && $variables['page']['content']['system_main']['#form_id'] == 'YOUR FORM ID') {
  if (arg(0) == 'node' && arg(1) == 'edit') {
    drupal_set_title(t('Edit Content');
  }
  else {
    drupal_set_title("Upload Content");
  }}
-2

Try this..

$node = node_load(your nid);
$node->title = 'new title';
node_save($node);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.