Error message

Notice: Undefined index: 4 in ckeditor_profiles_compile() (line 424 of /usr/home/sebdeb01/domains/bonardt.com/public_html/sites/all/modules/ckeditor/includes/ckeditor.lib.inc).

How to get Drupal Views render-as-link-fields W3C compliant

W3c compliant logo imageEdit jan. 2011: The solution below is outdated. Views has been updated and so has my knowledge of Drupal in the past years. ;). There are better ways to solve this.

I love Drupal. What's not to love about it? The steep learning curve? Come on, better stay with Wordpress then you. For al you other people who took the 'elbow greased' plunge like I did, a tip on the Views module. The Views module in Drupal allows you to make your own pages, blocks, etc with the content you would like to have on it from the different content types. There is no limitation! And that's what makes Drupal so great and flexible. Recently however, I stumbled upon a spec on this immaculate module.

It has to do with the fact you can write out a field with Views and have it render as a link. When this option is selected, it generates exactly what it should do. However....., those fields get an alt attribute (version used D6.x - Views2.8), and that's not what we want on the A tag. The XHTML Strict 1.0 doctype does not like 'alt' attributes in the A tag. In the IMG tag, ok. So how do we get rid of this and have a strict compliant page? It's easy!

In Views there is a function that generates this alt attribute and the title attribute as well. It's render_as_link or render_link which is located in the file modules/views/modules/node/views_handler_field_node.inc. Together with some code in modules/views/handlers/views_handler_field.inc approx. at line 517, the alt and title attributes are generated:

$alt = $this->options['alter']['alt'];
$alt = strtr($alt, $tokens);
if ($alt) {
$options['attributes']['title'] = $alt;
$options['attributes']['alt'] = $alt;

All you have to do is take out the piece of code that's writing out the alt attribute. Save it and see the alt disappear on all those links on your site! There's a patch or it as well on the Drupal site. More info can be found there as well.

drupal web development

2 comments

I have no idea what you're talking about, but it sounds cool. Nice looking site by the way,.... made with Drupal I presume?

by Kevin lucas on Thursday, 29/04/2010

I am not understanding that what are you saying and what is this Drupal but your site is looking very nice,

Post new comment

Copyright ©2005-2011 Sebastiaan Bonardt. All Rights Reserved.