1

I want to change the 'Create' label for a specific Content type.
I made a new content type called 'Bid Offer':

I want to show this to the users as 'Make Bid Offer' instead of 'Create Bid Offer'

Any help appreciated

2 Answers 2

1

Put the following code into a custom module.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'bid_offer_node_form') {
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
  }
}

or

function mymodule_form_bid_offer_node_form_alter(&$form, &$form_state, $form_id) {
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
}

To change the URL, you can just set a path alias and alias node/add/bid-offer to make-offer or whatever you fancy should you need to.

Just for reference:

hook_form_alter()

hook_form_FORM_ID_alter()

EDIT

Following on from your comment, please try the following code (I've used it recently so I know it works):

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'bid_offer_node_form') {
    drupal_set_title(t('Make Offer'));
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
  }
}

or

function mymodule_form_bid_offer_node_form_alter(&$form, &$form_state, $form_id) {
    drupal_set_title(t('Make Offer'));
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
}

Reference:

drupal_set_title()

3
  • thx, but I needed to change the Title Label instead of the Submit button. i39.tinypic.com/2d291md.png
    – wallace740
    Commented Apr 20, 2012 at 21:37
  • 1
    @wallace740 sorry for the late reply - I've edited my answer so it will now do what you need! I've left everything else there just inc ase it helps anyone else :-)
    – Chapabu
    Commented May 1, 2012 at 9:37
  • Thx a lot @Chapabu, this is exactly what I was looking for ! cheers :-)
    – wallace740
    Commented May 1, 2012 at 19:49
-1

Create bid_offer module with title callback returning node form. It should look like this (I didn't check it live!)

function bid_offer_menu_alter(&$items) {
  unset($items['node/add/bid_offer']); //unset core add path
}

function bid_offer_menu() {
   $items = array();
   $items['create/bid_offer'] = array(
     'title' => 'Create bid offer',
     'title callback' => 'bid_offer_title',
     'title arguments' => array(1),
     'page callback' => 'bid_offer',
     'page arguments' => array(1),
     'type' => MENU_CALLBACK,
     'access callback' => TRUE // You can customize this
   );


function bid_offer_title($type) {
  drupal_set_title(t('Make bid offer'));
  }
  return t();
}

function bid_offer($type = null) {
     if($type->type == 'bid_offer') {
       module_load_include('inc', 'node', 'node.pages');
       global $user;
       $new_node = new stdClass;
       $new_node->type = 'bid_offer';
       $new_node->language = LANGUAGE_NONE; //localization
       $new_node->user = $user->uid;
       $new_node->name = (isset($user->name) ? $user->name : '');
       $form = drupal_get_form('bid_offer_form', $new_node);
       return $form;
     }
   return drupal_not_found();
}

After that you're be able to create your bids from http://yoursite/create/bid_offer

You can change

'type' => MENU_CALLBACK

to MENU_NORMAL_ITEM for visible menu.

Important! Do not afraid of creating module. I'm not developer, just Drupal enthusiast and if you think logically you can make it.

4
  • I'm trying to create my module but I can't find "Create Bid Offer" label in my Node/Add form. i44.tinypic.com/283wh1.png
    – wallace740
    Commented Mar 23, 2012 at 17:53
  • I could not find the appropriate array element to change it :( I copied the array to here jsfiddle.net/5jWf7 Can you look at it if you have time? i44.tinypic.com/283wh1.png
    – wallace740
    Commented Mar 24, 2012 at 10:39
  • I wouldn't unset the node/add path. Just add an alias to said path.
    – Chapabu
    Commented Apr 19, 2012 at 13:26
  • This is actually MASSIVELY over complicated for the question at hand.
    – Chapabu
    Commented Apr 19, 2012 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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