How to add title attribute to views trimmed title field? The title field of a view is trimmed to 40 characters, and the Title field is linked to it's content. Since the Title field text is trimmed I need to add title attribute to the &lt;a&gt; tag of the Title field and the content of the title attribute must be the non-trimmed version of the Title field. So on mouseover event it should show the non-trimmed Title field text. How do I can do this?

I tried this 

 function THEME_preprocess_link(&amp;$vars) {
    // If title set and not empty dont do anything
    if (isset($vars['options']['attributes']['title']) &amp;&amp; !empty($vars['options']['attributes']['title'])) {
        return;
    }

    // Use the link text as the title
    $vars['options']['attributes']['title'] = strip_tags($vars['text']);
 }


But it shows the trimmed version as the title attribute.
you can accomplish this by overriding the field tpl file for the field and view:


assuming a View called 'title_test', and a field named 'title'
under Advanced, Theme, it gives the following option for the field tpl file: views-view-field--title-test--title.tpl.php
copy the modules/views/theme/views-view-field.tpl.php to your themes template folder, and rename it to views-view-field--title-test--title.tpl.php
replace the existing $output code with:

&lt;?php
    $field_output = l($field-&gt;last_render_text, $field-&gt;options['alter']['path'], array('attributes' =&gt; array('title' =&gt; $field-&gt;original_value)));
    print $field_output;
?&gt;

clear the cache


BE AWARE that this is overriding the default output by manually creating the link, so any special classes, or formatting included in the View must be added to this or you get unexpected behaviour (like missing classes, or field styling, etc). All of the information is available in the $field variable, you just need to extract it, for which Devel and dpm($field); will prove invaluable:


  Devel Helper functions for Drupal developers and inquisitive admins.
  This module can print a summary of all database queries for each page
  request at the bottom of each page. The summary includes how many
  times each query was executed on a page (shouldn't run same query
  multiple times), and how long each query took (short is good - use
  cache for complex queries). Also a dprint_r($array) function is
  provided, which pretty prints arrays. Useful during development.
  Similarly, a ddebug_backtrace() is offerred.