Exactly the same as http://drupal.org/node/263117 (which is D6), I would like to able to move the watcher link into the node-links section, and not the node-body, for D7. This way, when you use the D7 version of Links Block module I just finished, the watcher link will move too.
I read the patch for D6 and made similar changes to the current D7-dev. I cannot create patch files, but here is the code, if it could be implemented by a pro. I only did the changes that move the link, I didnt follow through and make the changes that modify the link text.
This block of code needs adding inside function watcher_theme($existing, $type, $theme, $path)
'watcher_node_links_toggle_watching_link' => array(
'variables' => array('uid' => NULL, 'nid' => NULL, 'query' => NULL, 'user_is_watching' => NULL, 't' => array()),
),This block of code needs adding inside function _watcher_admin_settings_watch_toggle_link(&$form
$form['togglelink']['watcher_toggle_link_position'] = array(
'#type' => 'radios',
'#title' => t('Where should "watch this post" toggle links be inserted on each node?'),
'#description' => t('This setting applies for both full page view and teasers (if the "display in teasers" option is checked).'),
'#options' => array(
'body' => t('At the bottom of the node body'),
'links' => t('In the node links section'),
),
'#default_value' => variable_get('watcher_toggle_link_position', 'body'),
); This block of code needs adding (makes sense to add after the function theme_watcher_node_toggle_watching_link($variables)
function theme_watcher_node_links_toggle_watching_link($variables) {
$user_is_watching = $variables['user_is_watching'];
// Set up classes
$class_watch_status_link = ( $user_is_watching ? ' watcher_node_toggle_watching_link_watched' : '');
return array( 'watcher-link' => array(
'title' => ( $user_is_watching ? $variables['t']['watch_toggle_enabled'] : $variables['t']['watch_toggle_disabled'] ),
'href' => "user/{$variables['uid']}/watcher/toggle/{$variables['nid']}",
'attributes' => array(
'class' => "watcher_node_toggle_watching_link$class_watch_status_link",
'title' => ( $user_is_watching ? $variables['t']['watch_toggle_enabled_title'] : $variables['t']['watch_toggle_disabled_title'] ),
),
'query' => $variables['query'],
),
);
} This block of code needs adding at the end of function _watcher_node_watch_link(&$node, $view_mode)Replace everything from the Add CSS line down.
// Add CSS
drupal_add_css(drupal_get_path('module', 'watcher') .'/css/watcher.css');
//Add element to node body or links section.
$position = variable_get('watcher_toggle_link_position', 'body');
if ($position == 'body') {
$node->content['watcher'] = array(
'#markup' => theme('watcher_node_toggle_watching_link', array('uid' => $user->uid, 'nid' => $node->nid, 'query' => $link_query, 'user_is_watching' => $watching, 't' => $tstrings)),
'#weight' => 30,
);
} else {
$node->content['links']['watcher'] = array(
'#theme' => 'links__node__watcher',
'#links' => theme('watcher_node_links_toggle_watching_link', array('uid' => $user->uid, 'nid' => $node->nid, 'query' => $link_query, 'user_is_watching' => $watching, 't' => $tstrings)),
'#attributes' => array('class' => array('links', 'inline')),
);
}
} | Comment | File | Size | Author |
|---|---|---|---|
| #5 | watcher-1599588-5.patch | 4.64 KB | neRok |
| #4 | watcher-1599588-4.patch | 4.7 KB | neRok |
Comments
Comment #1
neRok commentedA little tweak is also needed to the CSS, because when you click watch, the little eye-ball background appears all over the place.
If you change
to
it works good. Doesnt have to be div., just something needs adding to make that css property only apply to the link when it is placed in the node-body, not the node-links.
Comment #3
neRok commentedComment #4
neRok commentedMy first ever patch... hope it works!
Comment #5
neRok commentedWhat a flop. This one I tested (doh!).
Comment #6
kansaj commentedIs the patch working. I was not able to get it.
Comment #6.0
kansaj commentedRemoved some drupal_set_messages I had in the code to aid development.
Comment #7
nwom commented#5 works perfectly, applies against the current dev without problems, and is a great workaround when trying to add the Watcher link to panels (via Node Links pane). Thank you very much! Setting to RTBC.