mysite_type_hook_block

Definition

mysite_type_hook_block($arg, $op = 'view')
API.php, line 312

Description

Returns content to add to the MySite block.

This function checks the page that the user is on and returns MySite actions appropriate to the current path. While the return value is an HTML string, the $data array passed to mysite_block_handler() is key here. The $data array takes the format:

  • 'uid': The user id of the person viewing the page.
  • 'type': The content type defined by this include.
  • 'type_id': The id key for this particular page. That is, if viewing 'taxonomy/term/2', this value is '2'.
NOTE: As of 5.x.3, we no longer pass the 'title' element here. It is checked inside mysite_block_handler().

NOTE: The call to mysite_block_handler() is here rather than within mysite_block() in case the initial IF check fails. Doing so saves us needless function calls.

NOTE: In theory, you could add additional HTML to the $content, but mysite_block is expecting to receive the <ul><li>link to action</li></ul> content generated by mysite_block_handler(). Therefore, adding extra HTML is not recommended.

NOTE: This function does not handle block content for node pages. See mysite_type_hook_block_node().

See mysite_type_user_block() and mysite_type_term_block() for examples.

Invoked by mysite_block().

Parameters

$arg An array generated by mysite_block(). Consists of arg(0) through arg(5). Prevents calling arg() multiple times during the hook.

$op The block operation ($op) being performed. Always 'view'. Deprecated.

Return value

An HTML string to append to the MySite block, formatted by mysite_block_handler().

Related topics

Namesort iconDescription
MySite HooksInternal module hooks used by MySite includes.

Code

function mysite_type_hook_block($arg, $op = 'view') {
  global $user;
  if (user_access('access content') && ($arg[0] == 'mypath' && is_numeric($arg[1]))) {
    $data = array();
    $data['uid'] = $user->uid;
    $data['type'] = 'hook';
    $data['type_id'] = $arg[1];
    $content = mysite_block_handler($data);
    return $content;
  }
}