Solved

drupal profile 2

Posted on 2013-05-30
17
710 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

707 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

16 Experts available now in Live!

Get 1:1 Help Now