By tung_ct on
I follow the tutorial in chapter 6 of the book named "Packtpub.Drupal.7.Module.Development.Dec.2010.pdf"
this is an complex module named "Artwork" , so I just want to create simple one : "mybook drupal"
When I enable ArtWork module the administer menu has new item like below:(the rectangle with red borders)
link to image
and this is my code
function mybook_entity_info()
{
$return['mybook'] = array(
'label' => t('My book'),
'uri callback' =>'mybook_uri',
'base table'=> 'mybook',
'entity keys' => array(
'id' => 'bookid',
'revision' => 'vid',
'bundle' => '',
'label' => '',
),
'static cache' => TRUE,
'bundles' => array(),
);
return $return;
}
function mybook_uri($mybook)
{
return array('path'=>'mybook/'.$mybook->bookid);
}
/**
* Implements hook_permission().
*/
function mybook_permission()
{
return array(
'admin book' => array('title'=>t('Administer Books')),
'view book' => array('title'=>t('View book')),
'create book' => array('title'=>t('Create Books')),
'update book' => array('title'=>t('Update Books')),
'delete book' => array('title'=>t('Delete Books')),
);
}
/**
* Implements hook_menu().
*/
function mybook_menu()
{
$items = array();
$items['mybook'] = array(
'title'=> t('My Book'),
'access arguments' => array('admin book'),
'weight' => 0,
'menu_name' => 'management',
);
$items['mybook/addnewbook'] =array(
'title' => t('Add new book'),
//'page callback' => 'add_new_book',
'access arguments' => array('create book'),
'menu_name' => 'management',
'weight' => 0,
);
$items['mybook/showall'] =array(
'title' => t('Show all'),
//'page callback' => 'show_all_book',
'access arguments' => array('view book'),
'menu_name' => 'management',
'weight' => 0,
);
return $items;
}so what I get when I clear all cache is :
Click to link image
but when I enable my module and clear all cache , notthing is happen!
Can you fix it for me! thank alot ! I think the function "mybook_menu()" get some err, but I couldn't find out !
Thank a lot!
Comments
Why you have commented out
Why you have commented out the page callbacks? Not sure if that is the problem but it definetly will result in one as page callback is compulsory argument.
The issue is I commented out the page callback
Ok, I repaired it , my module working properly, thank you!