Solved

drupal profile 2

Posted on 2013-05-30
17
715 Views
Last Modified: 2013-06-18
Dear experts,

I am using profile2 to create a profile for each of my users. But there is something that my client requires and I don´t really know how to do. Each user is suppose to have different projects and each project is suppose to contain several pdf files. He wants to be able to create a project and assign it to the corresponding user profile.

I was thinking I could create a content type, say New Project. So when my client creates a New Project he will be able to assign that new project to an user.

Do you know a module that could let me do that?

thanks,

Winter
0
Comment
Question by:glepiza
17 Comments
 
LVL 13

Expert Comment

by:Arrow_1
ID: 39209815
Yes, that would work. You could create a content type of "Project" and add a field for referencing a user using the Entity Reference module.
0
 
LVL 17

Expert Comment

by:nanharbison
ID: 39210766
If you create a content type called Project, you can specify that it can have uploads of documents, and you can limit the number of documents if you need to.
0
 
LVL 9

Expert Comment

by:scifikillr
ID: 39211012
Another option (instead of using Entity Reference) is to use the References module.

You could create the content type as you suggest, and use the user reference to associate each node with a specific user. Then you could build a view which uses this userreference field to populate a block (which is only contextually available, based on a userID argument in the view) and load that block on the profile page. This would give each user the ability to see what is assigned to them currently.

Then, you can simply format/theme the node in such a way that the files are listed as you wish.
0
 
LVL 9

Accepted Solution

by:
scifikillr earned 500 total points
ID: 39211026
To make the view block, you would want to do something like this:

First, add the user reference field to the node.
Then:
1. Add a new view
2. Add the fields you want from the project nodes.
3. Add a "contextual filter" (e.g., argument). Select Default argument, and then "User ID from URL". If that is not available, you may first need to add a user relationship, then try again.
4. Add whatever sort method you like.
5. Set the block visibility to only exist on the profile page (or on a user-specific page).

This block will basically only show up if the following is true
1. If the page you're on is a user page (not a node, in this case)
2. If the page matches the visiblity settings you defined for the block.
0
 

Author Comment

by:glepiza
ID: 39211412
Hey guys thank you for your answers.

scifikillr,

do add an user relationship I guess I need to download user relationship module right ?

Another thing, just to see if I am doing it right, since I am not very familiar with the References module.
I added a new content type named Projects with the following fields:

Project name (as a text field)
Documents (as a file field )
User Reference (as a user reference field).

Then I went ahead and create a new view. I added the Project Name and Documents Fields. then I tried to add a contextual filter, but there is no Default argument to select, so as you suggested I need to add a user relationship. There is where I am stuck, to make an user relationship do I need to download the user relationship module or there is another way to do it?

Thank you very much,

Winter
0
 
LVL 9

Expert Comment

by:scifikillr
ID: 39211786
For the user relationship, you've already gotten that sorted (via the References module). If you actually need to add a Views Relationship, Views should be able to do that on its own.

For the argument:
I would check for an argument called "User:UID". That should work. I'll have to check my resources and get to you on this, otherwise. Please let me know if the above works.
0
 

Author Comment

by:glepiza
ID: 39211863
I don´t see an User:UID, but I am still looking where I get see it.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:glepiza
ID: 39211957
ok, I think I got the user id, but in mine it comes like the authors id. Now I am looking how to set the blocks visibility in views...
0
 

Author Comment

by:glepiza
ID: 39212016
Can someone please help me how to set blocks visibility only on the profile page?
0
 

Author Comment

by:glepiza
ID: 39212051
hmm , I think I did not get right contextual filters, I choose author uid but it seems I do need to user:uid, but I don´t see it.
0
 

Author Comment

by:glepiza
ID: 39212062
ok, I had to download user relationship module and now I get the user:uid. But now I don´t know how to set the block visibility to appear in profile pages..
0
 
LVL 9

Expert Comment

by:scifikillr
ID: 39216364
Block visibility can be set via the block settings page for the block in question. Navigate to Structure > Block, find the block, click 'Edit'.

Once on the edit page, scroll down to the section called 'Visibility Settings'. You have one of two choices:
1. Include on provided paths
2. Exclude on provided paths

The selection made above (include/exclude) will inform whether the paths. Using the example below with 'include' would result in the block appearing anywhere the first argument is equal to 'user':
user
user/*
0
 

Author Comment

by:glepiza
ID: 39220980
thanks for your answer. for some reason, User ID disappeared from contextual filter. I was deleting everything and when I wanted to added it back I just can´t see it anymore. But will will keep looking...
0
 
LVL 9

Expert Comment

by:scifikillr
ID: 39222340
If the field "disappeared" and you didn't delete it, then one of two things should be happening:
1. The field is replaced in the view by something called a 'broken views handler'. This is the representation of the field, but is reflected this way if the module that exposes this field/functionality is disabled.
2. Someone deleted the contextual filter from the view.

The UID relationship may be dependent on a relationship... I'm not sure. If so, it would explain the absence of the field. Adding relationships can sometimes expose other types of fields to the view (since views typically operate in a 'node' context, adding a relationship for something else would expose an entirely new set of fields)
0
 

Author Comment

by:glepiza
ID: 39257922
Ok, I ended up almost re building the view. Thank you all of you for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adjust the position 3 47
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 51
If-Then-Else ASP problem 6 47
Download a website to hdd 2 49
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now