I am doing something wrong and am not able to find what.
I have defined the hook_menu for my module, add and delete are working fine, but edit and view are not. Is like are never being called.
function nutrition_menu()
{
$items['admin/structure/ingredients'] = array(
'title' => 'Manage Ingredients.',
'description' => 'Manage Ingredients.',
'access arguments' => array('administer ingredients'),
);
$items['ingredient/%ingredient'] = array(
'title callback' => 'ingredient_page_title',
'title arguments' => array(1),
'page callback' => 'ingredient_page_view',
'page arguments' => array(1),
'access arguments' => array('view ingredients'),
'type' => MENU_CALLBACK,
);
$items['ingredient/%ingredient/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['ingredient/%ingredient/edit'] = array(
'title' => 'Edit',
'page callbacks' => 'ingredient_page_edit',
'page arguments' => array(1),
'access arguments' => array('update ingredients'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
);
$items['ingredient/add'] = array(
'title' => 'Add new Ingredient:',
'page callback' => 'ingredient_add',
'access arguments' => array('create ingredients'),
'weight' => 1,
'menu_name' => 'management',
'file' => 'ingredient.pages.inc',
);
$items['ingredient/%ingredient/delete'] = array(
'title' => 'Delete',
'page callback' => 'drupal_get_form',
'page arguments' => array('ingredient_delete_confirm',1),
'access arguments' => array('delete ingredients'),
'weight' => 1,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
);
return $items;
}
load functions
function ingredient_load( $iid = NULL, $reset = NULL)
{
$iids = (isset($iid) ? array($iid) : array() );
$conditions = array();
$ingredient = ingredient_load_multiple($iids, $conditions, $reset);
return $ingredient ? reset($ingredient) : FALSE;
}
function ingredient_load_multiple($iids=array(),$conditions=array(),$reset=FALSE)
{
return entity_load('ingredient', $iids, $conditions, $reset);
}
Callbacks
function ingredient_page_view($ingredient,$view_mode='full')
{
$ingredient->content = array();
field_attach_prepare_view('ingredient', array($ingredient->iid=>$ingredient),$view_mode);
entity_prepare_view('ingredient',array($ingredient->iid=>$ingredient));
$ingredient->content += field_attach_view('ingredient',$ingredient,$view_mode);
return $ingredient->content;
}
function ingredient_page_edit($ingredient)
{
var_dump($ingredient);
drupal_set_title(t('Edit @name', array('@name' => $ingredient->name)), PASS_THROUGH);
return drupal_get_form('ingredient_form',$ingredient);
}
Basically what I see is the two tabs ( View, Edit ) with no information bellow, the title isn't changing either.
Any idea?