-1

I have the item menu in my hook_menu.

//Calls a function that enables creating, updating and deleting ID Templates.
$items['user/%user/myid_templates'] = array(
    'title' => 'MyID Templates',
    'description' => 'Configuration for ID Templates',
    'page callback' => 'myid_templates',   
    'page arguments' => array(1),   
    'access arguments' => array('manage_templates'),
    'file' => 'includes/myid_templates.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -18,
);

It's working fine:

enter image description here

I want it to appear in the home page of my site. What shall I edit my code above? I tried the code below with no luck.

//Calls a function that enables creating, updating and deleting ID Templates.
$items[''] = array(
    'title' => 'MyID Templates',
    'description' => 'Configuration for ID Templates',
    'page callback' => 'myid_templates',            
    'access arguments' => array('manage_templates'),
    'file' => 'includes/myid_templates.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -18,
);
0

This should work

  $items['node'] = array(
    'title' => 'MyID Templates',
    'description' => 'Configuration for ID Templates',
    'page callback' => 'myid_templates',            
    'access arguments' => array('manage_templates'),
    'file' => 'includes/myid_templates.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -18,
);
  • $items['node'] is already used by the Node module, so another module cannot use it again. Also, the front page is not necessary that. – kiamlaluno May 27 '16 at 8:25
  • not working. :( – user46175 May 27 '16 at 8:33
  • @kiamlaluno --> so is it possible to place it in the front/home page? – user46175 May 27 '16 at 8:34
  • @kiamlaluno is correct that you can't use that path in hook_menu but you should be able to override with hook_menu_alter. First thing you need to do is determine what your frontpage is, you can check this by going to /admin/config/system/site-information and checking the value in default front page. Next you need to use hook_menu_alter to override the node modules callbacks with your own as per your original post. – Joseph Dempster May 27 '16 at 9:16
0

Create a block for that form and place it on your home page. I haven't actually tried it with argument but something like that should work, give it a try.


$items['homepage/%'] = array(
  'title' => t('My form'),
  'page callback' => 'drupal_get_form',
  'page arguments' => array('hook_myform_form',1),
  'access callback' => 'myform_custom_access_callback',
  'access arguments' => array(1),
  'type' => MENU_CALLBACK,
);

function hook_myform_form ($form, &$form_state,$user_id) {

}

function hook_BLOCK_myform_CONTENT() {
  return drupal_get_form('hook_myform_form');
}

function hook_block_info() {
  $blocks = array();

  $blocks['custom_myform_for_homepage'] = array(
    'info' => t('Details'),
  );
  return $blocks;
}

function hook_block_view($delta='') {
  $block = array();
  switch($delta) {
    case 'custom_myform_for_homepage':
      $block['subject'] = t("Details"); 
      $block['content'] = hook_BLOCK_myform_CONTENT();
      break; 
  }
  return $block;
}


Your Answer

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