I am trying to create a page in Views where it lists all the users and if they have created a content type of Member Portfolio then it puts a link next to the name to view that Portfolio.

I have a page that lists the users and under Relationships I have User:Content Authored. So it shows the user with a link to the content they created of all content types. If I try to filter in anyway of showing only the content type of Member Portfolio it only shows the users that have created a portfolio.

So what do I need to change/add/edit to have it list every member on the site and only put a link next to those who have created a Member Portfolio?

Comments

ryanfc78’s picture

Title: How To: List users with Link to Specific Content Type » How To: List users with Link to Specific Content Type?
saurabh.dhariwal’s picture

For your need create "User view" (i.e. admin/structure/views). So, that all user that avaliable in your website that list.
then add "Relationships">>"User: Content authored".

Add two fields:

1. "User: Name" set "Exclude from display".
2. "Content: Nid".

Override views templates file for nid field and write this code.

if(isset($row->node_users_nid) && !empty($row->node_users_nid)){
$node=node_load($row->node_users_nid);

if($node->type== 'tour'){
        $path='/node/'.$row->node_users_nid;
        $output ='<a href='.$path. '>' .$row->users_name .'</a>' ;
}
else {
        $output=$row->users_name; 
}
print $output; 
}

Let me know if you face any query/concern regarding this.

Thanks!

renatog’s picture

Status: Active » Reviewed & tested by the community

Hi guys

I tested #2 and works good.

Thank you @saurabh.dhariwal

renatog’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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