Commit d85c2d41 authored by merlinofchaos's avatar merlinofchaos

#132825: (lyricnz) Allow 'add comment' link as field.

parent a3026f80
......@@ -12,6 +12,9 @@ Views 4.7.x-dev
o #125973: (mfrederickson) Backport of internal views filter changes to 4.7 version.
o #138481: (fago) Allow 'delete' link to return to view like edit link does.
New features:
o #132825: (lyricnz) Allow 'add comment' link as field.
Views 4.7.x-1.6-beta3
o Reverting #130196: The original behavior was correct.
o #135829: Changed a bit how view table fields are defined to help prevent type confusion.
......
......@@ -61,6 +61,13 @@ function comment_views_tables() {
'addlfields' => array('uid'),
'help' => t('This will display the author of the node.'),
),
'add' => array(
'name' => t('Comment: Add link'),
'handler' => 'views_handler_comment_add',
'notafield' => TRUE,
'option' => 'string',
'help' => t('Display a link to add a comment to the node. Enter the text of this link into the option field; if blank the default "Comment" will be used.'),
),
),
'filters' => array(
'status' => array(
......@@ -348,3 +355,12 @@ function comment_views_default_views() {
return $views;
}
/**
* display a link to add a comment to a node
*/
function views_handler_comment_add($fieldinfo, $fielddata, $value, $data) {
if (user_access('post comments')) {
$link_text = $fielddata['options'] ? $fielddata['options'] : t('Comment');
return l($link_text, 'comment/reply/' . $data->nid, NULL, NULL, 'comment-form');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment