I've built a module with hook_perm, hook_access and hook_menu. Every menu item calls an include file within hook_menu like such:
$items['scoreos/teaminfo'] = array(
'title' => 'Team Info',
'page callback' => 'teaminfo_all',
'access arguments' => array('access team info'),
'file' => 'teaminfo.inc',
'file path' => drupal_get_path('module','scoreos')."/includes",
'type' => MENU_NORMAL_ITEM,
);
Therefore, none of the module's content is called until the menu item is clicked on. However, I'm now trying to add a block that I can place wherever I want, even the main page. I've added it below hook_menu like such:
function scoreos_standings_block($op = 'list', $delta=0, $edit=array())
{
if ($op == "list")
{
// Generate listing of blocks from this module, for the admin/block page
$block = array();
$block[0] = array('info' => t('Standings'));
return $block;
}
elseif ($op == "view")
{
//Code to save content to $standingscontent
}
$block['subject'] = "Standings";
$block['content'] = $standingscontent;
return $block;
}
I've put an entry in hook_perm and hook_access that emulates each of the menu items. The entry shows up in permissions. However, when I activate it in permissions, I can't find the block anywhere.
I think the problem is that I haven't linked the permission to this specific block but it's not clear to me how to do so. Hook_perm looks like this:
function scoreos_perm()
{
return array(
'other pieces of the modules',
...
'view standings',
);
}
and hook_access:
function scoreos_access($op, $node, $account)
{
switch ($node)
{
case 'otherpieces':
return user_access('other pieces of the module', $account);
...
case 'standings':
return user_access('view standings', $account);
}
}
Thanks for plugging through and thanks in advance for the help.
Comments
Bump - any help on this would
Bump - any help on this would be appreciated.
The
The line
is incorrect.
In general it would be
Delta could be a number (0) or a string ("Standings").
So in your case you might use
For more information on hook_block see Declaring block content, Generating the block content and hook_block
Thanks, I was going of an
Thanks, I was going off an example without thinking through what was behind it. Not the right way to do it. I appreciate the help.
Unfortunately, that didn't solve it. I still have no entry in the list of blocks to add. I'll edit the code in the original post to match what it looks like now and will continue to dive into it.