Closed (fixed)
Project:
Drupal core
Version:
6.5
Component:
comment.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Oct 2008 at 06:32 UTC
Updated:
25 Jun 2011 at 19:26 UTC
Hi-
This is my first drupal bug, please excuse me if I submit it wrong ;)
When trying to implement hook_link via the API doc example, it doesnt work. http://api.drupal.org/api/function/hook_link/6 depicts in the code example supposedly how to use hook_link:
function hook_link($type, $object, $teaser = FALSE) {
$links = array();
if ($type == 'node' && isset($object->parent)) {
if (!$teaser) {
if (book_access('create', $object)) {
$links['book_add_child'] = array(
'title' => t('add child page'),
'href' => "node/add/book/parent/$object->nid",
);
}
if (user_access('see printer-friendly version')) {
$links['book_printer'] = array(
'title' => t('printer-friendly version'),
'href' => 'book/export/html/'. $object->nid,
'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
);
}
}
}
$links['sample_link'] = array(
'title' => t('go somewhere'),
'href' => 'node/add',
'query' => 'foo=bar',
'fragment' => 'anchorname',
'attributes' => array('title' => t('go to another page')),
);
// Example of a link that's not an anchor
if ($type == 'video') {
if (variable_get('video_playcounter', 1) && user_access('view play counter')) {
$links['play_counter'] = array(
'title' => format_plural($object->play_counter, '1 play', '@count plays'),
);
}
}
return $links;
}
I tried this in my own example, and it didnt work, see http://drupal.org/node/319298; KJL figures out int http://drupal.org/node/319298#comment-1085568 that there are '#' signs missing from the array keys. I'm not sure if its just limited to the 'title' and 'href' keys, or if all the keys need the '#', or not.
Please correct in API docs.
thanks,
geremy
Comments
Comment #1
dddave commentedThe api-comments suggest that the stuff is correct. If you feel otherwise please re-open.