Hi,

Instead of linking from individual fields, I would like the entire row of my view to be active as a link. I would also like to be able to highlight it with a border or background when the user hovers over it.
I found a similar post here: http://drupal.org/node/444762
The difference is that I am using "unformatted" style instead of "table" and hoping that in my case this is easier to achieve.

My site is here:
http://romantikpensionen.de/
The view I am referring to is the three pictures next to each other near the bottom of the front page.

Does anyone have a suggestion?

Cheers,
Jim

Comments

WorldFallz’s picture

I don't think table or unformatted makes much difference, i don't think its a trivial task either way. Making it highlight on hover is just a matter of styling :hover (only works on anchor tags in ie6 btw) with css appropriately. To make a whole row link, I would think you'd have to theme the row to include some jquery like:

$url = <whatever from the row holds the info for the link>;
drupal_add_js('
$("#viewname tr#uniquerowid").click(function () { 
  window.location.href = $url;
});
',inline);
JimNastic’s picture

Hi,

Thanks for your suggestion. Actually someone on IRC made another suggestion. I will post it here so if anyone else has the same question they can choose.

I hid most of the fields in the view then did rewrite output of the remaining field to include the other hidden fields. This meant that all the fields were within the anchor. Here's the code within the "rewrite output" box:

<div class="views-field-title">
    [title]
</div>
<div class="views-field-field-region-image-fid">
     [field_region_bild_fid] 
</div>

Additionally you need to enter the path in the "Link Path" box:

node/[nid]

Note that [title], [field_region_bild_fid] and [nid] are "replacement patterns" enabling substitution by views 2 of my views fields into the output.

Cheers,
Jim

WorldFallz’s picture

clever! Thanks for posting it back.

leanne9’s picture

Finally!! Solved my problem, too-- thanks JimNastic!

pacharas’s picture

How to rewrite output? And where's the "rewrite output" box? which page?
Thanks.

pacharas’s picture

Thank you.
I've managed to get it after some trial&error.

Collins405’s picture

thanks!

/chris