Is there a way to use the fields in the Views modules to insert a link to the user's contact page? I have seen some modules and blocks which have this feature but I just want a simple table with the user name and a link to their contact page. Can it be done without using a contrib module?
Thanks!

Comments

lonehorseend’s picture

I don't care if I have to use a contributed module though. What module(s) did you find?

JuLearn’s picture

Any solutions? - I am facing the same problem.

kepesv’s picture

Hi!
1., Let's add a field to view: UID
2., There is a views-view-table.tpl.php in the sites/all/modules/view directory. Copy it to your theme directory and rename it: views-view-table--your_view_name.tpl.php
3., Modify it.
e.g.:

...

<tbody>
    <?php foreach ($rows as $count => $row): ?>
      <tr class="<?php print ($count % 2 == 0) ? 'even' : 'odd';?>">
        <?php foreach ($row as $field => $content): ?>
          <td class="views-field views-field-<?php print $fields[$field]; ?>">
            <?php 
				if ($fields[$field] == "uid" ) 
				print '<a href="?q=user/'.$content.'/contact">Send message</a>';
				else 
				print $content; 
				
	    ?>
          </td>
        <?php endforeach; ?>
      </tr>
    <?php endforeach; ?>
  </tbody>

...
BrianLewisDesign’s picture

Or just rewrite the [iud] field in views (and don't forget permissions):

relationship - Content:Author
field - Content: Author uid
- REWRITE RESULTS - Rewrite the output of this field [X]

<a href="?q=user/[iud]/contact">Send Email</a>