Output link as plain text is wrapped in div tags, which interferes with theming views

Benjamin Melançon - March 12, 2008 - 15:45
Project:Link
Version:5.x-2.1
Component:Code
Category:support request
Priority:normal
Assigned:Benjamin Melançon
Status:closed
Description

Add field formatter 'Plain, as link' is marked as closed – note that in that case the patch submitters intention was to have a linked URL, which is not yet an option – but the option to output of a truly plain URL does not yet exist.

Instead, the URL is wrapped in div tags:

<div class="field-item">http://www.example.org/link.html</div>

Which isn't the end of the world until you're trying to make a pretty view (aka the views theme wizard) and would like to use the link field directly with no formatting. Then it is the end of the world, as far as functioning links are concerned. With both $title and the CCK link field, $field_resource_link_url, set to plain, and this code in the view template:

<?php
print l($title, $field_resource_link_url);
?>

The title works fine and the CCK link field trashes the URL:

A nice plain title with no div nor h2 tags

I think it's the responsibility of Link to provide a truly plain version of the data it stores, leaving mark-up to themers who wan that control.

Patch forthcoming.

benjamin, Agaric Design Collective

#1

quicksketch - March 12, 2008 - 16:38

CCK is the one adding that wrapped DIV around the result. I think it's put in there when the default code output by views theming wizard calls views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);. Prior to that the field is properly just the URL. I don't think there's anything at the link.module level that can be done.

#2

Benjamin Melançon - March 12, 2008 - 20:13
Category:bug report» support request
Status:active» fixed

Thanks quicksketch!

I had figured that out, and after a ridiculously long trip through the innards of views theming, I found the obvious user interface solution:

When editing the view, be sure to set the field handler for your link plain url to Do not group multiple values, and no divs will be wrapped around it.

/headdesk

benjamin, Agaric Design Collective

#3

Anonymous (not verified) - March 26, 2008 - 20:22
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.