Posted by ChadH-1 on February 5, 2008 at 8:10pm
Like many, I'm creating a networking site. While I'm new to Drupal, I've worked with PHP, HTML, CSS, etc. My question is what is the best way to allow a user to add multiple items to their profile? For example we'd like our users to add their work history to their profile. Since we can't tell how many jobs someone's had, we'd like the option for adding, editing and deleting each job individually (similar to LinkedIn). So do we create CCK modules to enter the information? Use nodes for each job and add a view for them on the profile page? We're currently looking at User Profile, but that can change. Any feedback would be helpful.
Thanks,
ChadH
Comments
If you use one of the
If you use one of the profiles as nodes modules (bio or nodeprofile) you can add cck text fields (which themselves can have multiple values) to the profile content type for users to fill in. It sounds like that would cover most of what you want.
I went with Advanced Profile
I'm using nodeprofile and ended up using Advanced Profile to achieve what I was looking for. I basically created a nodeprofile content type for work experience and created the form using CCK. I then used a view to display all the work experience nodes for the specific user. I turned that view into a panel and embedded that panel into the life-saving Advanced Profile. Now when you go to a user profile page it has a Work History section listing their various jobs. If you're looking at your profile page, you can add/edit/delete work history nodes from the embedded view.
Glad to hear it worked out
Could you possibly provide a link to the end result, i.e., the user profile page that shows the Work History section? I'm just curious as to how it looks.
Much appreciated!
Walt Esquivel, MBA; MA; President, Wellness Corps; Captain, USMC (Veteran)
$50 Hosting Discount Helps Projects Needing Financing
Walt Esquivel, MBA; MA; President, Wellness Corps; Captain, USMC (Veteran)
$50 Hosting Discount Helps Projects Needing Financing
What I did:
Here's a quick summary of how I created a way for a user to enter multiple pieces of work experience and how to display it on the profile page. I'm using quite a few modules, the most important being: nodeprofile, Advanced Profile, panels and views.
<?phpglobal $user;
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) == $user->uid)
{ echo l('Add Position', "node/add/experience", false, "destination=user/".$user->uid); }
?>
This code will display an "Add Position" link for adding new work experience items when looking at your profile page. It will not display the link if you're looking at someone else's profile page.
<?phpglobal $user;
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) == $user->uid)
{ echo l('Add Position', "node/add/experience", false, "destination=user/".$user->uid); }
?>
This code will display an "Add Position" link for adding the first new work experience item when looking at your profile page and you don't have any work experience items yet. It will not display the link if you're looking at someone else's profile page.
Add another argument type of "Node: Type" default "Summary, sorted as view" (this limits it to only experience items)Handled by step 8 - Feb 14, 2008if (arg(0) == 'user' && is_numeric(arg(1))) { return array(arg(1),'experience'); }This sets the arguments that are passed in (ie use the profile users's ID and limit to only 'experience' content)
Use this instead - Feb 14, 2008
if (arg(0) == 'user' && is_numeric(arg(1))) { return array(arg(1)); }This sets the arguments that are passed in (ie use the profile users's ID)
In the Filter section, add "Node: Type" and choose your Experience content type. This is the better way of limiting the view to just Experience items
In the Filter section, add "Node: Published" and choose "Yes". This limits your view to just published experiences
Let me know just how intelligible you found this "walk-through" and if it actually helped anyone else. There's a screenshot of your profile as you see it and a screenshot of your profile as seen by someone else. Obviously there's still some CSS and HTML work that needs to be applied, but the basics are there.
Updates - Feb 14, 2008
Ok, having worked with this a bit more and learned more about Drupal I found a couple changes that needed to be done. In particular using the Filter to limit to only Experience content types instead of jumping through the Argument Handling hoops. Hopefully this is still legible.
ChadH, Your tutorial is
ChadH,
Your tutorial is great, thanks!
Two questions, you said you are using Advanced profile, so are you also using the bio module instead of nodeprofile? In the tutorial for Adv. profile it says its only working with bio for now.
Is it possible to do what you did using nodeprofile and usernode? I didn't really want to use adv. profile because of all the patches to cck that it seems to require etc.
...
Advprofile has been working with nodeprofile for quite some time. You only need to patch CCK if you don't want to use the dev version. It was committed a long time ago but there hasn't been a new release.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
I've been using nodeprofile
I've been using nodeprofile with Advanced Profile for a while now without any problems. In fact I'd highly recommend the Advanced Profile since it saved me a lot of time and head-ache setting up the profile page for me (thanks Michelle).
Unfortunately I don't know how/if you can do it with nodeprofile and usernode. I'd guess you can, but I'm still pretty new at Drupal. I got lucky/had everything click in place to get the experience to work like I wanted to.
Cool, but Panel Views?
That's great, Chad. I don't really fully understand the reason for panel views. I've been just adding my Views straight in to my panel pages. I looked at it, but didn't really get it.
Can anyone explain why panel views exist and why I should use them? =)
Views
Greg - If you're the one that will be modifying the panel pages then sticking the views right on there is easier and perfectly fine. Despite the name, legacy views isn't going away. The reason you would want to use panel views is if you are expecting someone else to be administering the panels and want a cleaner interface. By enabling only panel views, you get only those views in the add content. If you have 50 views on the site but only 3 are used for panels, that simplifies it quite a bit. I also used them for advprofile because I can label them all with "advprofile" and they group together nicely on the add content popup.
(You're welcome, Chad :)
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
Thanks!
Thanks Michelle - that makes sense. I was wondering. Now the mists have cleared! =)
Doesn't Show View, Edit, Delete
Chad and others,
I have followed Chad's instructions, however the "View", "Edit", and "Delete" links do not appear below the item. The "Add Position" link does appear at the top of the view when viewing your own page.
Is this an option that can be set somewhere? In the View editor? In the Portfolio View editor? In the theme template?
Also, I did not use step 7 regarding the argument handling code. Is this necessary? It shows the correct items without that step.
Thanks for your help.
--Spencer
Updated:
Never mind, I figured it out. I didn't realize that those links were added as fields within the Views editor.