Kommentare an anderer Stelle positionieren
dereine — 27. Juli 2008 - 20:29
Gestern Abend kam die Frage ob man die Kommentare auch an anderer Stelle als unter dem Node anzeigen könnte. Nach dem Nachlesen im Quellcode war sofort klar, dass es dafür bisher keine Themefunktion gibt. Eine anderer Lösung als Themefunktionen sind in dr6 der Hook hook_menu_alter($callbacks), welcher die Menu Struktur verändern lässt und man so wirklich alles verändern kann
/**
* Implementation of hook_menu_alter()
*/
function custom_comment_menu_alter(&$callbacks) {
dsm("hier");
$callbacks['node/%node']['page callback'] = 'custom_comment_node_page_view';
}
function custom_comment_node_page_view($node, $cid = NULL) {
drupal_set_title(check_plain($node->title));
return custom_comment_node_show($node, $cid);
}
function custom_comment_node_show($node, $cid, $message = FALSE) {
if ($message) {
drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))));
}
$output = theme('custom_comment_node_show', $node, $cid);
// Update the history table, stating that this user viewed this node.
node_tag_new($node->nid);
return $output;
}
function theme_custom_comment_node_show($node, $cid) {
$output = node_view($node, FALSE, TRUE);
if (function_exists('comment_render') && $node->comment) {
$output .= comment_render($node, $cid);
}
return $output;
}
/**
* Implementation of hook_theme()
*/
function custom_comment_theme() {
return array(
'custom_comment_node_show' => array(
'arguments' => array('node' => NULL, 'cid' => NULL)
)
);
}
?>



Kommentar hinzufügen