I would love to be able to add the title attribute to Views links. For example <a href="url to a node" title="how do I add this title?">Link within a page with a View applied to it</a>. I went through views.module to look for a place to add something like array('title' => $node->title); but didn't have any success. I know very little about PHP :-(

I display my Views as tables so I'd imagine that this modification for the title attribute would have to go here within view.module?:


/**
 * Display the nodes of a view as a table.
 */
function theme_views_view_table($view, $nodes, $type) {
  $fields = _views_get_fields();

  foreach ($nodes as $node) {
    $row = array();
    foreach ($view->field as $field) {
      if ($fields[$field['id']]['visible'] !== FALSE) {
        $cell['data'] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node);
        $cell['class'] = "view-field view-field-$field[queryname]";
        $row[] = $cell;
      }
    }
    $rows[] = $row;
  }
  return theme('table', $view->table_header, $rows);
}

Any help would be greatly appreciated. I'm sure this isn't that hard for most Drupal coders? Thanks in advance :-)

Comments

merlinofchaos’s picture

Views has a lot of links in a lot of places; this actually might be a little harder than it sounds. Can you be more specific in what situation you want said links to be changed?

jrstmartin’s picture

It's so simple it's confusing, it's confusing just trying to explain it :-) I would like to add the title attribute to all title links in a view. For example, my home page is a view, displaying new and popular content - I would like the links to the content to have a title attribute. The title should be automatically generated and can be the same as the link text - the $node->title or whatever.

This is to satisfy my SEO paranoia. I'm hoping I can insert a small patch into views.module somewhere...

merlinofchaos’s picture

Status: Active » Closed (won't fix)

If you're using a 'list' or a 'table' view, your best bet is to theme the actual field.

The easiest way to do that is to use the views_theme_wizard which will give you the code needed to theme all of your fields, and then you can modify it, hopefully appropriately.

This isn't something that's going to get into views, though; you're going to have to figure out how to do it.