0

I would like to display a view block on a custom tab I created as follows, but the tab is always empty. The block has the option to be shown only on specified path node/%node/calendario-corsi. Is it correct to have an empty page callback?

function custom_morebuttons_menu() {

  $items['node/%custom_node_calendario_corsi/calendario-corsi'] = array (
   'title' => 'Calendario corsi',
   'page callback' => 'custom_node_calendario_corsi_page',
   'page arguments' => array(1),
   'access callback' => 'user_is_logged_in',
   'type' => MENU_LOCAL_TASK,
   'weight' => 10,
  );

  return $items;
}


function custom_node_calendario_corsi_load($arg) {

  $node = node_load($arg);

  if($node->type == 'centro' || $node->type == 'sede') {

    return $node; }

  return FALSE;
}


function custom_node_calendario_corsi_page($arg) {

  return '';
}
0

Should be next:

function custom_morebuttons_menu() {
  $items['node/%node/calendario-corsi'] = array(
    'title' => 'Calendario corsi',
    'page callback' => 'custom_node_calendario_corsi_page',
    'page arguments' => array(1),
    'access callback' => 'user_is_logged_in',
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );

  return $items;
}

function custom_node_calendario_corsi_page($node) {
  $node = node_load($arg);
  if (($node->type == 'centro') || ($node->type == 'sede')) {
    // I assume you will add some behaviour code for this, next make no sense.
    return $node; 
  }
  return false;
}
  • The resulting page is still empty. The block is not rendered. – Danilo Brambilla Feb 7 '13 at 10:28
  • also the tab is showing on all content types. – Danilo Brambilla Feb 7 '13 at 16:04
0

This is my working solution:

function custom_morebuttons_menu() {

  $items['node/%custom_node_calendario_corsi/calendario-corsi'] = array (
   'title' => 'Calendario corsi',
   'page callback' => 'custom_node_calendario_corsi_page',
   'page arguments' => array(1),
   'access callback' => 'user_is_logged_in',
   'type' => MENU_LOCAL_TASK,
   'weight' => 10,
  );

  return $items;
}


function custom_node_calendario_corsi_load($arg) {

  $node = node_load($arg);

  if ($node->type == 'centro' || $node->type == 'sede') { return $node; }

  return false;
}


function custom_node_calendario_corsi_page($node) {

  if ($node->type == 'centro') { return views_embed_view('centro_autenticato_calendario_corsi', 'block_1', $node->nid);

  } else if ($node->type == 'sede') { return views_embed_view('sede_autenticato_calendario_corsi', 'block_1', $node->nid); }
}    

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.