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')),
    );
  }
}  
CommentFileSizeAuthor
#5 watcher-1599588-5.patch4.64 KBneRok
#4 watcher-1599588-4.patch4.7 KBneRok

Comments

neRok’s picture

A 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

watcher_node_watched {
  background-image: url(../images/watch.gif)!important;
}

to

div.watcher_node_watched {
  background-image: url(../images/watch.gif)!important;
}

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.

neRok’s picture

neRok’s picture

Status: Needs work » Needs review
StatusFileSize
new4.7 KB

My first ever patch... hope it works!

neRok’s picture

StatusFileSize
new4.64 KB

What a flop. This one I tested (doh!).

kansaj’s picture

Is the patch working. I was not able to get it.

kansaj’s picture

Issue summary: View changes

Removed some drupal_set_messages I had in the code to aid development.

nwom’s picture

Status: Needs review » Reviewed & tested by the community

#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.