How to link a view row to a node? I'm using the Message module to notify users when someone reacted on their nodes. I'm now trying to theme the messages, which are displayed in a view, called 'Message'.

I'd like to link a message to the content that's commented on. In other words: when a user clicks a message, he/she should be linked to the corresponding node's page. I don't simply want the message text to be a link, but the whole message (i.e. also including the other fields) should function as some kind of 'button'.

I think the easiest way to do this is to create a views-view-unformatted--message.tpl.php file and use

&lt;?php foreach ($rows as $id =&gt; $row): ?&gt;
  &lt;div&lt;?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?&gt;&gt;
   &lt;a href="&lt;?php print url('$url'); ?&gt;"&gt;
    &lt;?php print $row; ?&gt;
   &lt;/a&gt;
  &lt;/div&gt;
&lt;?php endforeach; ?&gt;


The problem is that I don't know how to define $url. I can store the needed nid in the message and add it hidden to the view, but I can't find a way to grab that information.

How can I do that?
I stored the nid from the node that's commented on in a message field and used the information in a views-view-unformatted--message.tpl.php file.

&lt;?php if (!empty($title)): ?&gt;
  &lt;h3&gt;&lt;?php print $title; ?&gt;&lt;/h3&gt;
&lt;?php endif; ?&gt;
&lt;?php foreach ($rows as $id =&gt; $row): ?&gt;
  &lt;?php $message = message_load($view-&gt;result[$id]-&gt;mid); ?&gt;      
  &lt;div &lt;?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?&gt;&gt;
   &lt;a href="&lt;?php if (isset ($message-&gt;field_nid['und'][0]['value'])) {
                      print url('node/'.$message-&gt;field_nid['und'][0]['value']);} ?&gt;"&gt;
    &lt;?php print $row; ?&gt;
   &lt;/a&gt;
  &lt;/div&gt;
&lt;?php endforeach; ?&gt;