When the similar entries module is installed, it creates links to pages with similar content. The link is missing the title tag making the code html strict invalid.

Example:

<a href="http://localhost/test-page-2">test page 2</a>

The link should be constructed as follows:

<a href="http://localhost/test-page-2" title="Test page 2">test page 2</a>

Current code in the theme_similar_content() function in similar.module:

          array(
            'attributes' => variable_get('similar_rel_nofollow', 0) ? array('rel' => 'nofollow') : NULL,
            'absolute' => TRUE
           )	

I am not using nofollows, so I modified it like this:

          array(
            'attributes' => array('title' => ($content->title)),
            'absolute' => TRUE
          )

Comments

xjessie007’s picture

Here is an update to make it work with the nofollow too.

Current code:

    if ($teaser) {
      $items[] = '<div class="similar-title">'.
        l($content->title,
          'node/'. $node->nid,
          array(
            'attributes' => variable_get('similar_rel_nofollow', 0) ? array('rel' => 'nofollow') : NULL,
            'absolute' => TRUE
          )
        ) .
        '</div><div class="similar-teaser">'. check_markup($content->teaser, $content->format, FALSE) .'</div>';
    }
    else {
      $items[] = l(
        $content->title,
        'node/'. $node->nid,
        array('attributes' => variable_get('similar_rel_nofollow', 0) ? array('rel' => 'nofollow') : NULL)

Updated code:

    variable_get('similar_rel_nofollow', 0) ? $ar_attributes = array('title' => ($content->title), 'rel' => 'nofollow') : $ar_attributes = array('title' => ($content->title));

    if ($teaser) {
      $items[] = '<div class="similar-title">'.
        l($content->title,
          'node/'. $node->nid,
          array(
            'attributes' => $ar_attributes,
            'absolute' => TRUE
          )
        ) .
        '</div><div class="similar-teaser">'. check_markup($content->teaser, $content->format, FALSE) .'</div>';
    }
    else {
      $items[] = l(
        $content->title,
        'node/'. $node->nid,
          array(
            'attributes' => $ar_attributes
          )
        );

This will make the similar.module work to reflect both nofollow settings as well as to display title in the link HTML code.

(Sorry, I do not know how to make a patch, and I am not a programmer either, so I am just posting the suggested change in the code here as a FYI.)

----
Maxi-Pedia

jordojuice’s picture

That is fine. Thanks for the work. This will be committed probably tonight. Sorry that it took so long to respond. I just took over development of the module as the previous maintainer was tied up in other work. I'm working to clear out the queue and get bug fixes in, though.

jordojuice’s picture

Status: Active » Closed (fixed)

This has been committed to dev and will go in the next release. Thanks for the work! : )