Shell Multimedia

Mostly Drupal for now -- Photography coming soon!

User Profiles Version 1

Mon, 05/14/2007 - 00:05 -- Michelle

This is the original tutorial from last May. It has since been replaced by a newer version. See the User Profiles page for details.

Goal: The aim of this tutorial is to walk you through every step you need to create a user profile like this one.

Notes:

  • This tutorial assumes Drupal version 5.x
  • This does not use the core profile module or the bio module
  • The steps assume you want a profile exactly like mine. Most likely you'll want to do different things for your profile. I will try to provide alternates where possible but I'm not going to explore every possible permutation. I'll mark these alternates with [DIY...]
  • This tutorial only discusses the one user = one profile page method. You can get much more advanced using multiple nodes and pageroute, but that's beyond the scope of this tutorial.
  • You will be told to add things to your template.php file. If your theme doesn't have one, create a blank file in your theme with this name. The snippits are shown surrounded by (without the spaces) so the codefilter picks them up. You only need one

    Modules needed:

    • Automatic Nodetitles - Not strictly needed, but it's handy so users don't have to put a title on their profiles and to keep the title consistant. If you don't use this, you'll need to adjust node-uprofile-edit.tpl.php so users can enter a title.
    • Buddylist - Allows users to designate other users as their "buddy". We will show a list of buddies on the profile page.
    • CCK - We need this to create the content type for nodeprofile to use. Also enable the field type modules that come with it as well as content copy.
    • Contemplate - Makes it easier to theme the profile. If you are adept at theming, you can skip this and use .tpl files instead.
    • Date - CCK date field used for birthdate. Also needs the adodb date library if you have people born before 1970. Just unzip it into the date directory.
    • Guestbook - Allows others to comment on a profile in a bit more organized way than simply enabling comments.
    • Link - CCK link field.
    • Node Profile (5.x-1.1 or later) - This is what allows us to make profiles out of nodes.
    • Node Profile Bonus - This has the code for taking over the user view page as well as fixes for the registration page. The plan is to include this with NodeProfile but is available attached to this tutorial for now. Until it's part of the package, you'll need to manually copy nodeprofile_bonus.module and nodeprofile_bonus.info into your nodeprofile module directory.
    • Node Family - Required by Node Profile
    • Panels - We will actually only be using the CSS from this because I suck at CSS layout. If you can handle the CSS on your own, you don't actually need this module for this tutorial.
    • Private Message - We will check if the user allows private messages and add a link to do it if so. If you don't want private messaging on your site, you can skip this. Be sure to take out the reference in the contemplate code.
    • Subform Element - Required by Node Profile
    • Token - Used by auotmatic nodetitles
    • Usernode - This is used for the buddylist view.
    • Views - We will use this for the user's recent posts, the buddy list, and also searching users. Don't forget to enable the views UI module as well.

    Step 1 - Getting prepared

    1. Download and install all the above modules.
    2. Set the user access control (?q=admin/user/access) for: buddylist, guestbook, privatemsg, user module (access user profiles) like like this.
    3. Configure buddylist (?q=admin/settings/buddylist) and privatmsg (?q=admin/settings/privatemsg) to taste. See guestbook section below before bothering with config.
    4. Set usernodes to not be promoted to front page (?q=admin/content/types/usernode)
    5. Download the file User-Profile-Tutorial.zip attached to this tutorial. This contains as much of my profile as I was able to export to save you time copying and pasting.

    Step 2 - Creating and configuring the profile content type
    Create the content type (see note at end of "Add the fields" section):

    1. Go to Administer -> Content Management -> Content Types -> [Add Content Type] (?q=admin/content/types/add)
    2. Expand "Automatic title generation". Check the box and put in [author-name]. [DIY: You can choose another token or add text if you prefer a different title for profiles.]
    3. Name: User Profile
    4. Type: uprofile
    5. Description: Whatever you want
    6. Title field label: Leave as title as the user won't see it (unless you've elected to not use auto nodetitles)
    7. Body field label: Empty this out as we don't need the body
    8. Default options: Uncheck promoted to front page
    9. Maximum population: 1
    10. Check "Use this content type as a nodeprofile for users"
    11. Comments / attachments / pms: Disable all of these
    12. Save content type

    Add the fields:

    1. Go to Administer -> Content Management -> Content Types -> [Import] (?q=admin/content/types/import)
    2. Content type: User Profile
    3. Paste in the contents of "User-Profile_uprofile-cck-fields.txt" found in the attached zip. Click submit. [DIY - Edit the User Profile content type and manually add all the fields that you want users to enter in their profile.]
    4. Your content type should now look like screenshots/User-Profile-Content-Type.jpg

    Note: The reason I had you create the content type first and then import into it is that there seems to be a bug with groups not getting created when you create the content type at the same time. You can get around this by doing the import twice if you don't want to manually create the type.

    Fix the fields display:

    1. Edit the User Profile content type you just created and click the tab for "Display Fields" (?q=admin/content/types/uprofile/display)
    2. Change all the aboves for the fields to inlines. This doesn't come across with the importing, unfortunately.
    3. Submit

    Set the nodeprofile options:

    1. Edit the User Profile content type you just created and click the tab for "Node profile" (?q=admin/content/types/uprofile/nodeprofile)
    2. Keep unchecked "Integrate this node profile with user categories."
    3. Check "Show this node profile during user registration." [DIY: Leave unchecked if you don't want it on the reg screen]
    4. User page display style: Display it as full node view
    5. Uncheck "Include an edit link to the display"
    6. Weight: 10 (this makes it come under username/email on the registration page but is unneeded otherwise)
    7. Submit

    Access control:

    1. Go to Administer > User management > Access control (?q=admin/user/access)
    2. Set the permissions on "create uprofile content" and "edit own uprofile content".

    Step 3 - Avoiding naming collisions

    DON'T DO THIS STEP!!! If you've already done it, undo it. It breaks usernode!

    To avoid having your usernode and nodeprofiles having the same titles, edit the usernode content type (?q=admin/content/types/usernode) and change the autotitle token to something else. I used "Usernode of [author-name]". The user will never see this, but it's nice to make it clear to admins which is which.

    Step 4 - Take over the user account view tab
    By default, the nodeprofile module will put your user profile as a section on the user account view tab (located at /user/#). This is fine for simple profiles but doesn't look right for a full featured profile. [See screenshots/User-Account-Default-View.jpg]

    This step makes the user profile take over the entire view tab. The downside is that you will lose anything that other modules add to this page. If you add a module that normally has a link on the user view page, make sure you provide alternate access to it. If you are fine with the way it displays by default, you can skip this step.

    1. Make sure the node_profile_bonus module is enabled. This has code for removing everything that's not a profile from the page and also adds an "Edit Profile" tab to the user account page for easy access.
    2. If you want to change your Edit tab to Edit Account to make things clearer, you can add the uncommented code into your template.php. If you don't already have this function, add in the commented code as well (uncomment it). Don't forget that you only need one //function _phptemplate_variables($hook, $vars) {
      // if ($hook == 'page') {
      if (arg(0) == 'user') {
      $vars['tabs'] = str_replace('Edit', 'Edit Account', $vars['tabs']);
      }
      // return $vars;
      // }
      //}
      ?>
    3. Add this code to your template.php:
      // Override the display of the nodeprofile to just show the node itself and not the surrounding markup or the tabs.
      // Theming of the nodeprofile will be handled separately. Note that this affects it wherever it is displayed and
      // not only on the user page.
      function phptemplate_nodeprofile_display_box($element, $content) {
      $head = isset($element['#title']) ? '

      '. check_plain($element['#title']) .'

      ' : '';

      return $content;
      }

      // Override the entire user account view page to not show the categories or to seperate items into divs.
      // Note that this is set up to still show everything that is thrown on this page. Getting rid of non-nodeprofile
      // sections is done in the node_profile_bonus module by unsetting them but could also be done here by conditionally
      // printing them to begin with.
      function phptemplate_user_profile($account, $fields) {
      foreach ($fields as $category => $items) {
      foreach ($items as $item) {
      $output .= $item['value'] ;
      }
      }

      // Returning nothing from this function causes the entire page to whitescreen, so let's put something in by default
      // A better idea might be to load up some sort of standard thing that has the views and just not the profile fields
      if (empty($output)) {
      $output = "This user has not filled out a user profile.";
      }

      return $output;
      }
      ?>

    Your user account page (?q=user/1) should now look like this: screenshots/User-Account-After-Page-Take-Over.jpg

    Step 5 - Taxonomy
    My profile uses taxonomy for some of the fields. I did this so you can click on a term and see all the other users with that term. With some coding, the taxonomy is used as though it was a normal CCK field.

    Go to Administer > Content management > Categories (?q=admin/content/taxonomy). Create the following vocabularies: Communities, Hobbies, Reading, Music, TV and Movies. Communities is a multi select with the terms entered in via add term. The others are freetagging. Note: If you add these in a different order or choose different vocabularies, you will need to alter the contemplate code and the input form to match.

    [DIY - Most people reading this are not going to want preset communities. Feel free to skip that vocab and add it as a normal CCK text field if you want and I'll make notes where you need to delete references to it later.]

    Attach each of these vocabularies to your User Profile content type.

    Step 6 - Add the views

    1. Go to Administer > Site building > Views > [Import] (?q=admin/build/views/import)
    2. Import the contents of User-Profile_User-tracker-view.txt. Submit and save the view. This view will display all the posts by a particular user.
    3. Import the contents of User-Profile_Buddylist-view.txt. Change the filter for node type to usernode. I don't know why this doesn't import correctly. Submit and save the view. This view will display the photo and name of all the user's buddies from the buddylist module.
    4. To theme the buddylist view so that we get rid of the list markup, add this to your template.php.
      function phptemplate_views_view_list_buddylist_of_uid($view, $nodes, $type) {
      $fields = _views_get_fields();

      $taken = array();

      // Set up the fields in nicely named chunks.
      foreach ($view->field as $id => $field) {
      $field_name = $field['field'];
      if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
      }
      $taken[$field_name] = true;
      $field_names[$id] = $field_name;
      }

      // Set up some variables that won't change.
      $base_vars = array(
      'view' => $view,
      'view_type' => $type,
      );

      foreach ($nodes as $i => $node) {
      $vars = $base_vars;
      $vars['node'] = $node;
      $vars['count'] = $i;
      $vars['stripe'] = $i % 2 ? 'even' : 'odd';
      foreach ($view->field as $id => $field) {
      $name = $field_names[$id];
      $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
      if (isset($field['label'])) {
      $vars[$name . '_label'] = $field['label'];
      }
      }
      $items[] = _phptemplate_callback('views-list-buddylist_of_uid', $vars);
      }
      if ($items) {
      //MAC Instead of returning an item list, we just seperate with spaces
      //return theme('item_list', $items);
      return implode(" ",$items);
      }
      }
      ?>

    5. Copy views-list-buddylist_of_uid.tpl.php to your theme directory. This formats the view to just show photo and name with no extra divs. The end result of this, the step above, and the CSS that will be added later is a mini thumbnail gallery of buddies.

    A screenshot isn't possible at this point because these additions won't show up on the profile page until you add the contemplate templates.

    Step 7 - Add the guestbook
    The guestbook has been tweaked quite a bit to work as a commenting system on the profile page. This has made some of the options on the guestbook module non functional:

    • Anonymous users are not allowed to add entries.
    • Comments are turned off. (Instead, it's been modded so the user can post to his/her own guestbook.)
    • The pager is hard coded in the .tpl and ignores the options.
    • The add comment form is always on the page and not just linked to.

    Directions:

    1. Copy guestbook.tpl.php to your theme dir. This controls the overall display of the guestbook section
    2. Copy guestbook-entry.tpl.php to your theme dir. This controls the display of a single guestbook entry
    3. Copy guestbook-form-entry-form.tpl.php to your theme dir. This controls whether the entry form or a note is displayed
    4. Add this code to your template.php:

      // These overrides load custom .tpl files to handle the guestbook display as a whole, a single entry display, and the input form
      function phptemplate_guestbook($uid, $entries, $comment_entry, $limit = 20) {
      return _phptemplate_callback('guestbook', array('uid'=>$uid, 'entries'=>$entries, 'comment_entry' => $comment_entry, 'limit' => 20));
      }

      function phptemplate_guestbook_entry($uid, $entry, $comment_entry = NULL, $confirm_delete = false) {
      return _phptemplate_callback('guestbook-entry', array('uid'=>$uid, 'entry'=>$entry, 'comment_entry' => NULL, 'confirm_delete' => false));
      }

      function phptemplate_guestbook_form_entry_form($form) {
      return _phptemplate_callback('guestbook-form-entry-form', array('form'=>$form));
      }
      ?>

    5. While modifying module code is not recommended, there were a few changes I couldn't find a better way to do. I've put my modified version of guestbook.module into the zip file. You will need to overwrite the stock guestbook.module with this. All my changes are marked with //MAC and commented. If a new version of guestbook comes out, these changes will need to be merged in. That's why modifying modules is a bad idea. If anyone has a better way of doing it, I'd love to hear it. These are the changes:
      • Added a separate query so the guestbook on the profile page shows the last 5 entries with newest on top and the regular guestbook page shows them with oldest on top.
      • Removed the title from the text area on the add entry form as it was redundant.
      • Allowed users to post on their own guestbook
      • Changed the link on the poster's name/photo to go to their profile rather than their guestbook.

    A screenshot isn't possible at this point because these additions won't show up on the profile page until you add the contemplate templates.

    Step 8 - Theming the profile
    I use the contemplate module to make theming the CCK nodes easier. If you are proficient in theming, you can use .tpl files instead.

    1. Go to Administer > Content management > Content templates and click on "Create Template" for User Profile. (?q=admin/content/templates/uprofile)
    2. Check "Affect teaser output" and paste the contents of User-Profile_Contemplate-teaser.txt into the "Teaser Template" box.
    3. Check "Affect body output" and paste the contents of User-Profile_Contemplate-full-node.txt into the "Body Template" box.
    4. If you are not using clean URLs, you will have to adjust the links for the taxonomy terms.
    5. Correct the path, if needed, in this line right at the top: drupal_add_css("sites/all/modules/panels/layouts/twocol_stacked.css");
    6. Submit to save the changes.

    Your account view page should now look like screenshots/User-Account-Before-CSS.jpg

    Get rid of submitted by / time on profile:
    Note:You can skip this if you use the provided node-uprofile.tpl.php since it doesn't print the post info.

    1. Go to Administer > Site building > Themes > Configure > General Settings (?q=admin/build/themes/settings)
    2. Uncheck "Display post information on" for User Profile
    3. Save Configuration

    Other theming:

    1. The CSS used for the user profile can be found in User-Profile-CSS.txt. Paste the contents of that file into your theme's .css file and edit to taste.
    2. Copy the "profile" directory into the "images" directory of your theme. This contains icons used by the contemplate code.
    3. Copy the node-uprofile.tpl.php to your theme directory for a stripped down node display that just shows the content.

    Step 9 - Theme the input form
    The default input form you get after adding all the fields and taxonomy to your usernode can be overwhelming, so I moved things around and simplified them. If you want to use my simplified edit form:

    1. Add node-uprofile-edit.tpl.php to your theme directory.
    2. Add this code to your template.php to call it:

      function phptemplate_node_form($form) {
      if ($form['#node']->type == 'uprofile') {
      return _phptemplate_callback('node-uprofile-edit', array('form' => $form));
      }
      else {
      return theme_node_form($form);
      }
      }
      ?>

    3. Because the taxonomy terms are given by number instead of name, you may need to adjust this file if the terms don't show up as they should.
    4. If you opted to not make a term for community, leave out this part:
      print "Which community do you live in? If you don't live in the area, you can leave this blank.";
      print drupal_render($form['taxonomy']['1']);

    Step 10 - Searchable view of profiles

    1. Go to Administer > Site building > Views > [Import] (?q=admin/build/views/import)
    2. Import the contents of User-Profile_User-listing-view.txt. Submit and save the view. This view will display a filterable list of all users with profiles.
    3. If your taxonomy is not set up as Communities, Hobbies, Reading, Music, TV and Movies numbered 1-5, the view will complain. You'll have to edit the view to change the numbers before importing.

    Note: - If you want to display all users regardless of whether they have profiles, you will need to get the views_fusion module. There are instructions on drupal.org on how to use it but, honestly, I couldn't figure it out. Since I have the nodeprofile on the registration page, all users will have profiles, so I elected to take the easy way out and just do a view on nodeprofiles.

    Step 11 - Known issues

    • Admin created accounts don't work right
    • After adding / editing nodeprofile, it sends you back to the nodeprofile node, not the user screen
    • User listing view sends you to the nodeprofile node

    Step 12 - Further plans

    • There's a div set aside for the user's gallery. At this point, I haven't added image handling to my site, so I haven't done this section of the profile. It should just be a matter of inserting a view there, though, or perhaps a call to one of the image handling module's display.
    • Selectable color scheme. I was thinking it would be nice to have a few different CSS options for users. Not quite on the level of MySpace but maybe allow them to choose from a pre-defined list. This could be done by adding another field to the nodeprofile and a little code to load CSS based on the value.
    • Limit viewing to people on buddy list. I'd like to give users the option to hide their profile information from anyone who's not on their buddylist. This would work in conjunction with setting the buddylist option to make people get approval before adding someone as a buddy. I haven't looked into the best way to do this, but it shouldn't be too hard to determine if the logged in user is a buddy and use if tests around the printing of the fields to control the display.

Comments

Submitted by Visitor on

I started this tutorial from scratch as a newb would and have stopped at step 2 because of the following:

Step 1 part 2:
In access control-->node module, there is no create uprofile or edit own uprofile ( yes I have all the needed modules enabled)

Needed for Step 2:
There is no download for your attachment for Node Profile Bonus

Step 1 part 3:
Configure buddylist and privatmsg to taste, umm what does taste mean?

Buddylist requires the invite module which works fine but maybe you should list it since its needed.

Submitted by greenbuilder on

Hi there,

Great tutorial. I'm investigating similar options to this and using your tutorials as a template. I am unable to find node_profile_bonus however. This means that I have unwanted tabs on my user profile page right now.

I'm also having an issue where this profile is being created for new users, but is not applying to existing users.

Any suggestions for these items would be greatly appreciated.

Thanks,
Nathan.

Submitted by Admin on

The node_profile_bonus is in the zip file attached to the article.

Existing users will need to click on the edit profile tab and that will add the node if it doesn't already exist.

Michelle

Submitted by Admin on

uprofile is the name of the content type we're creating. It doesn't exist, yet, in that step.

The download is there. I just didn't have the permissions on this site configured correctly for anon users to view it. Fixed now.

Configure to taste means configure them how you want.

Buddylist does not require the invite module, and this tutorial does not use the buddylist_invite module, so it's not listed.

Michelle

Submitted by Havran on

Hi. Great tutorial. I found missing image in Step 8:

Your account view page should now look like >screenshots/User-Account-Before-CSS.jpg<

Submitted by Anonymous on

Hi Michelle
your tutorial is eaxctly what I'm looking for - but I've got stuck at this bit:
"Set the nodeprofile options:"
I can't find the nodeprofile tab on the uprofile content type I just created - have I done something wrong?
Debs

Submitted by Anonymous on

yay - Hi Michelle - I found my own problem - I went back to the start and checked on versions - you wrote "Node Profile (5.x-1.1 or later) - This is what allows us to make profiles out of nodes." - I had an older versions and as soon as I upgraded it worked.
thanks again - this is a great tutorial (especially when I do as you say ;-)
Debs

Submitted by tourguide on

I took a few notes on paths for each step..

Step 1. #2: ?q=admin/user/access

#3: ?q=admin/settings/buddylist
?q=admin/settings/buddylistautoadd
?q=admin/settings/privatemsg

#4: ?q=admin/content/types/usernode

----------------------------------------------------

Step 2. #1: path(s) provided
#2: "[author-name]" leave out the quotes

Fix the "Field" display #2: "Label" column, ignore "Group" display

Avoiding naming collisions: ?q=admin/content/types/usernode

Submitted by lecourageux on

...so much for this tutorial. As I'm quite new to PHP and Drupal it helped me a lot to accomplish a main requirement of my users. By the way, your Profile has now swept over the Atlantic sea to Germany, as the site I'm building is a german social site. If you wanna see your profile in german, follow that link: http://oppen-haal.de/user/4

Good nite (over here it's 03.10 a.m.)!

Submitted by greenbuilder on

Thanks,

I had an older zip from your dev version of this article.

Again, great tutorial.
nathan.

Submitted by Sam Rosen on

Hi Michelle,

Fantastic tutorial--a real service you've provided here. Quick question: would I add the expanded .zip folder as its own module to install uprofile? If not, how should I go about installing those files in my Drupal site?

Thanks,
Sam

Submitted by Admin on

The zip file isn't a module. It's a collection of files used by this tutorial. As you go through the tutorial, it will refer to the files and tell you what to put where.

Michelle

Submitted by Admin on

That was an error in copying from the dev site.

Michelle

Submitted by Admin on

I added in all the paths. Thanks.

Michelle

Submitted by Admin on

Unfortunately, it looks as though you need to be logged in to view it.

I'm curious what people are doing with their profiles, so feel free to add links. :)

Michelle

Submitted by Cory on

This is VERY VERY informative and has helped me tremendously. I noticed someone mentioned that they were getting a foreach() error. You mentioned that you weren't sure exactly what it was, but I just figured I'd post since I have the same error. Well, at least a similar one (actually 5).

If anyone has any idea on what might be causing the errors below, I'd be very appreciative.

Once again, GREAT write-up Michelle.


1. warning: Invalid argument supplied for foreach() in /home/styledes/public_html/sites/cincytucky.com/modules/views/views_query.inc on line 81.

2. warning: Invalid argument supplied for foreach() in /home/styledes/public_html/sites/cincytucky.com/modules/views/views_query.inc on line 16.

3. warning: Invalid argument supplied for foreach() in /home/styledes/public_html/sites/cincytucky.com/modules/views/views_query.inc on line 189.

4. warning: Invalid argument supplied for foreach() in /home/styledes/public_html/sites/cincytucky.com/modules/views/modules/views_node.inc on line 777.

5. warning: Invalid argument supplied for foreach() in /home/styledes/public_html/sites/cincytucky.com/modules/views/views_rss.module on line 55.

EDIT: I managed to get rid of number 5. by simply disabling the Views RSS Module. However this worries me, if I ever want to use it.

EDIT 2: After even more research, I have determined that it is not the User Listing or User Tracker Views. Unfortunately I am blocked at work from viewing the actual .inc's to figure out what the problem is. More to come hopefully.

EDIT 3: I've gone through the Contemplate scripts and found a few areas where my vocabularies weren't in the same order as they should have been within the array (not sure if this matters, so i cleaned it up anyway). I fixed that and now have even more errors. However, I think I forgot a step, so tonight I'm going to go through it and hopefully everything will turn out ok.

BTW, sorry for the multiple edits. Just wanted to leave the current progress. I'll clean the post up once I figure out what's going on.

EDIT 4: Okay, so I went back through everything to make sure I had it all right and unfortunately, I did. I was actually hoping I didn't so it would possibly fix the errors. Does anyone have any idea what this could be? I looked at the views_query.inc file but I'm not sure exactly what it is doing or which view it isn't liking. The digging continues!

Submitted by Admin on

I've got the views errors, too. Everything works just fine so I thought it was some glitch on my system but now I've seen other people reporting the same thing. If anyone could hunt this down, I'd appreciate it. I'm not sure how much computer time I'm going to have for the next week so it may be a while before I can look at it.

Michelle

Submitted by Gurukripa on

one thing that would be very much needed is to make the users searchable. Is this possible with this way of doing things.

and secondly, I am completely unaware of how to code..so will u help out later..if we shift to this way of having user info..and then we need to integrate some info onto it ?

also which modules are we overriding by this method?

can you provide some real life user profile to check? i dont mind registering on ur site..if i can see how things actually look.
thanks

Submitted by Admin on

"one thing that would be very much needed is to make the users searchable. Is this possible with this way of doing things."

See step #10.

"and secondly, I am completely unaware of how to code..so will u help out later..if we shift to this way of having user info..and then we need to integrate some info onto it ?"

I've been providing support in answering questions in comments as best I can. I can't make any guarantees on my time, but I do my best.

"also which modules are we overriding by this method?"

The only module that gets messed with is guestbook. I try to avoid hacking existing code as much as possible but I couldn't find a way to do the guestbook changes with overrides so I did make a few edits there.

"can you provide some real life user profile to check? i dont mind registering on ur site..if i can see how things actually look."

There's a screenshot of the finished profile at the top. If you want to see it live, you can play on the test site. I made the screenshot because I can't guarantee that test site will last as long as this tutorial is being used or that I won't totally mess it up testing something else, but it works for now.

Michelle

Submitted by Dave on

Hey Michelle, great write up!

I followed all the steps provided, and for whatever reason, my admin profile is showing up on the front page. I tried tinkering around with some settings and couldn't figure it out. Do you happen to know what I did wrong? Thanks!

Submitted by Admin on

Go to config content types and edit uprofile and scroll down to the bottom and make sure you don't have promote to front page checked. Do the same for usernode as well just to be sure.

Michelle

Submitted by Dave on

These options were already left unchecked...wonder what it could be?
Thanks.

Submitted by Anonymous on

Thanks for the great tutorial :)

I made sure that 'promote to frontpage' was deselected on both node types, as you instructed above. The node was stilling appearing on the frontpage. Then I went to administer->content management->content and selected the node. The 'publish to frontpage' option was checked. When I deselected it and pressed submit, I got the following error:

You mustn't change the title. Change the name of the user and the title is going to be updated.

Submitted by Dave on

After trying what you did, it worked for me! I'm not sure of the error you're getting but I'll try to recreate it if possible.

Submitted by seth97 on

I had the same problem as you describe. I think I solved it.
If you go to administer->content management->content (?q=admin/content/node) and instead of clicking on "edit" for a specific content (a specific user), you select it and choose "Demote from front page" in the drop down above ("Update options") and press update. This worked for me.

I am a little confused: All users have a "User Profile" (?q=admin/content/node), except for user 1 (admin) who only has a "Usernode". And then I have another user that has both a "User Profile" and a "Usernode", whereas all other users only have "User Profile". Could be some problem with users created before I went through the excellent Michelle-tutorial...?
Thanks!

Submitted by Admin on

Weird... Are you using automatic nodetitles? That's based on the author of the node so if you change the author I guess maybe you could get that. It's not something I've run into. I guess check that the author is still set to the person the profile belongs to. Other than that, I'm drawing a blank.

Michelle

Submitted by Admin on

User profiles (the nodeprofile's content type) are not created automatically like usernodes are. They are created the first time you click on the "Edit profile" tab. If you go the route of putting it on the registration screen, they are created automatically but only as users register. They are not created retroactively for existing users as usernodes are.

Michelle

Submitted by Cory on

Well, I've hit step 5 and the errors are all ready occuring. I was trying to track down where it started to take place but forgot to enter any information. After completing step 5 I entered my info and the errors appeared.

Also, as a test, i entered text in every field and still got the errors. Another odd thing is, I added a term to the Communities vocabulary and selected it in my "Edit Profile" tab and then saved it. Well for whatever reason, it didn't save and my Community section still shows up empty on my profile page.

Hopefully this info will be of some help to someone. I'll try and do this again and enter information to try and pin point the exact step that the errors start to occur.

Submitted by Denney on

To fix the known issue of "After adding / editing nodeprofile, it sends you back to the nodeprofile node, not the user screen", you can use the Node Go To module.

After enabling the module, goto the administration section for the module (admin/settings/nodegoto) and, under the paths for INSERTING and UPDATING, set the path to "user" for the User Profile node.

That will redirect the user back to their profile page.

Submitted by Arindam on

Hi Michelle,

Can this same thing be done for Drupal 4.7 or would it require some changes to the codes that you have given here. Plus of course, there is no node_profile_bonus module for 4.7 etc. Its a very nice and lucid tutorial though....its a pity 4.7 version drupallers can't use it :-(.

Submitted by VascoW on

Hi!

It seems your tutorial is exactly what i'm looking for. But i stuck at step 2 with adding the fields.
My drupal don't have an import funktion at that place. Even when I try to went directly to the link, I don't get what I'm looking for.
[quote]
Add the fields:
1. Go to Administer -> Content Management -> Content Types -> [Import] (?q=admin/content/types/import)
[/quote]

Can you assit whits that? What is missing?

Submitted by Admin on

I suspect you missed this step:

CCK - We need this to create the content type for nodeprofile to use. Also enable the field type modules that come with it as well as content copy.

Michelle

Submitted by Admin on

To use it on 4.7 you'd have to make sure all the modules used are on 4.7 as well as backporting any features that were added to the 5.x version like with nodeprofile. I also don't know if the theming stuff, etc would work. So I'd say not very possible with out a heck of a lot of work and figuring things out on your part which would make this tutorial pretty useless.

Michelle

Submitted by Admin on

Thanks for this. I'll try to take a look at it and incorporate it into the tutorial.

Michelle

Submitted by Admin on

Thanks to EclipseGc, I think this is solved. Views wants string arguments. It works fine with numeric arguments but complains. So the views need to be:

print views_build_view('embed', $view, array(strval($profileuser->uid)), false, false);

I'll fix up the contemplate file and re-up the zip when I get a chance.

Michelle

Submitted by Joeboris on

My 'admin' has both a Node Profile and a Usernode. However, all my following 'users', created by 'themselves' (as in not by admin) have Node Profiles, but no Usernodes... This, of course, won't allow their buddies to display on their profile-pages, leaving them in quite a sad state. I created all the 'users' after completing the tutorial, and the Node Profile is a part of the registration... Any ideas?

On another note: Thank you so much for the tutorial, Michelle! I've been very unsure of how to do my profile pages, and this will do the trick perfectly!

-Joeboris

Submitted by Denney on

Bah... Sorry about that... Again...

What I was saying is that your Contemplate code creates URL's manually using the "a href" tags. In order to support URL aliases and do things the Drupal way, you should replace them with the following:

l($item->name, "taxonomy/term/" . $item->tid)

Also, when I click on one of those terms, it takes me to a "Currently no posts found" page. What are the links meant to show?

Submitted by Cory on

Looking forward to it...THANKS, to both you and EclipseGirl.

Although, I'm getting the errors before even using the contemplate formatting. Hopefully using it fixes it. Can't wait to find out.

Submitted by Admin on

Yeah, my bad on that. I forget to use l sometimes.

Where it takes you is the standard taxonomy listing page. It's the same place you'd get if you showed the tags normally in your node.tpl.php. Weird that you're getting nothing found, though... You should be getting the nodeprofiles of the people with those tags.

Michelle

Submitted by Admin on

Usernodes are created automatically and it also retroactively creates them for existing users when you install the module. If your admin account has a usernode then you've obviously installed the module... I looked under access control and there's nothing there for creating usernodes so that's not it. All I can think of is try uninstalling and reinstalling the usernode module. Something went screwy but I can't say what. :(

Michelle

Submitted by Admin on

I added the contemplate file as another attachment for now. I need to go through all the comments and fix things that have been suggested and generate a new set of files. But I'm half asleep, so not tonight. :) In the mean time, there's the file that will hopefully fix the views errors for you.

Michelle

Submitted by VascoW on

Thanks Michelle,

perfect support. Thanks for your quick answer!

Submitted by Denney on

Well, at the moment, I'm the only user account with that taxonomy set. Should it display my account on that page along with everyone else's? I believe it should. I'll have to look into it more and find out why it's not showing any profiles.

Submitted by gurukripa on

:)
sorry to bother u more..
in ur post u also mention that the profile page is being overridden..and hence in case some other module is linking into it...we need to do this separately...
wld this be an issue later on..

one more thing...
cld u provide some extra fields to include things we need for our profiles..and where all changes made to it have to be made ...

the other thing i cant understand is where are the settings to make changes to way things are arranged on the page...divisions etc..and how to make changes to the colors of the bars or sizes etc..

thanks

Submitted by Admin on

If you don't want to override the profile page, skip that part. It's only an issue if you add a module that puts stuff on the profile page and don't offer any other way to get to it.

I have no way of knowing what extra fields you need for your profiles. This tutorial shows you how to get from point A to point B. If you want to go to point C instead, you'll need to do a little researching to understand what you need to change.

The last bit is all CSS. That's where you need to make your changes.

Michelle

Submitted by Admin on

If you are the only user with that term, it should just show you. Basically the idea is that if you click on "Dr Who" in someone's profile you get a listing of all the users who have "Dr Who" in their profile.

It's really just normal taxonomy tags just manipulated a bit to look like part of the tutorial instead of hanging out in the footer.

Michelle

Submitted by Admin on

As I mentioned in (your?) post on drupal.org, I just discovered this morning that I've been affected by this as well. I'm going to investigate it during my son's nap in a bit. If anyone else is having this problem, please speak up.

Michelle

Submitted by Admin on

I spent 3+ hours tracing through the form submission code today and finally found the problem. Autonodetitles on usernode causes it to silently fail validation. Turning that off fixes it. Which explains why some of my users have usernodes because that was a late addition to the tutorial when I realized I was having a naming conflict with nodeprofile.

I'll take that out of the tutorial again. Not sure what to do about the naming issue. It's not a huge deal as you are allowed to have duplicate titles... it just makes it more confusing remembering which is which.

Michelle

Submitted by Denney on

You might want to rethink using the Node Go To module. The following is the problem:

Make sure you have email validation of new accounts enable. Make sure you have the profile to show on the registration page.

Now, when a new user registers, they're taken to the profile page and the validation email doesn't get sent!

Submitted by Denney on

I've fixed the problem now. Seems that my profile got unpublished somehow so it wouldn't show on the taxonomy screen...

Submitted by Admin on

I hadn't had a chance to look into it, yet. Got bogged down yesterday spending over 3 hours figuring out that usernode and auto nodetitles don't get along. :(

Michelle

Submitted by Denney on

I worked out that, if the Node Profile is set to show on the registration screen, you can use Node Go To and just set the "UPDATE" location to point to "user". As the Node Profile is created when registering, there is no need to set the "INSERT" location so Node Go To can still be used to redirect users when editing their profiles.

Submitted by droople on

Hi Michelle

I am setting up a site for players and fans both with browsable feature rich profiles, like this tutorial aims to achieve.

I created a fans profile (user profiles) using your tutorial, it worked well

Then trying to do a player profile I named content-type_name === player profile, i named the content_type === pprofile

using the same ckk fields, i imported the information from the txt file, edited out a few fields and groups on the content-type

I am using the module, "role signup"

I setup permissions, basic user and players

only "basic users" can create user profile nodes, according to my permissions settings and "player" role can create player profiles content.

However, this is not the practical case,

When the "player user" goes to edit their profile it still shows the "user profile" fields

Do you have a clue what might be wrong ?

Submitted by Denney on

I worked out the reason why my profile was "unpublished". I was using your "node-uprofile-edit.tpl.php" file. I removed the bit about the administrator so that only the few fields would be shown.

It seems that if you don't have the published field shown, your profile will automatically return to being unpublished.

Submitted by Denney on

I'm having the problem of auto nodetitle not working when the user fills out the registration form. The node is created but the title is just their author name and doesn't have the "Profile of" part before it.

If the user creates a profile after they register (I was the only one who was able to do this because I had an account before node profiles was installed) it creates the nodetitle correctly with "Profile of [author-name]".

If a user whose profile was created at registration then goes and edits their profile, the title changes to the correct "Profile of [author-name]" title. Strange that filling out the profile during registration seems to bypass the auto nodetitle module.

Submitted by Admin on

Oh, interesting... I copied that bit of code from someone else and didn't realize it had a side effect. It's a bit of a hacky way of doing it, anyway. I'll add investigating a better way to my ever growing to do list.

Thanks,

Michelle

Submitted by Admin on

I have this nagging feeling that I ran into this but can't remember how or even if I solved it. I'll try and find a bit of time this weekend to investigate and see if I can figure it out.

Michelle

Submitted by Admin on

There are some places where uprofile is hardcoded because I didn't know how to find the name of the content type dynamically. You'll need to check through the files for "uprofile" and conditionally change that to "pprofile". I don't know for sure if that is the problem you're having, but I know that will cause problems in general since it's assuming "uprofile" in those cases.

Michelle

Submitted by cat4mba on

Hey Michelle
Thanks for Such an excellent article.

I tried to follow all the steps given above but something seems to have gone wrong.
I can view the complete profile at node http://Mysite.com/node/xxx
But for the same user @ http://Mysite.com/user/xxx I could see only the community, Joined date etc but not any thing from the CCK field.
What could have gone wrong?

Submitted by droople on

Adding this uncommented code to the template.php


function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {
if (arg(0) == 'user') {
$vars['tabs'] = str_replace('Edit', 'Edit Account', $vars['tabs']);
}
return $vars;
}
}

Adding the commented code

//function _phptemplate_variables($hook, $vars) {
// if ($hook == 'page') {
if (arg(0) == 'user') {
$vars['tabs'] = str_replace('Edit', 'Edit Account', $vars['tabs']);
}
// return $vars;
// }
//}

nothing changes, do you have an idea of the exact code I should paste to have the "EDIT" to "EDIT ACCOUNT"

thanks

Submitted by Francis on

Michelle, thank you for your work, this is awesome!

One thing I would like to say is, that I ran into problems, because my template uses subfolders. The template.php is in the main theme folder, your .php files should go to the theme subdirectory. Took me some time to realize this ;-)

I have a question: How can I limit the shown links to user articles?
Let's say, I just want to show their recent 10 or 20 entries and provide a "1 2 3 4 next page last page" navigation at the bottom.

Thanks in advance,

Francis

Submitted by Kristen on

Hi. This is a truly awesome tutorial! I've figured out almost everything except for one thing: how do I get the buddylist links to link to the user profile instead of the nodeprofile? Thanks!

Submitted by diggersf on

You can fix the "After adding / editing nodeprofile, it sends you back to the nodeprofile node, not the user screen" issue using hook_form_alter().

I added the following code to node_profile_bonus.module:

<?php

function nodeprofile_bonus_form_alter($form_id, &$form) {
if ($form_id == 'uprofile_node_form') {
$form['#submit']['nodeprofile_bonus_node_form_submit'] = array();
}
}

function nodeprofile_bonus_node_form_submit() {
drupal_goto('user/' . arg(1));
}

?>

This tells drupal to send the user to the proper user page after the node has been created/updated.

Submitted by kristen on

I added the following to nodeprofile_bonus.module, as explained in Views->Theme Wizard

<?php

function phptemplate_views_handle_field_node_title($fields, $field, $data) {
//return however you want your link to look... the picture actually links fine, it was just the name that linked to the wrong place.
}
?>

Submitted by manocha_ak on

thanks Michelle,

awesome tutorial.... though i m newbee... it helped me a lot

Submitted by manocha_ak on

hi Seth,

I thought like it has something to do with the auto title checkbox checked in the "uprofile" content type generation....

and tried to give "field_first_name" instead of author-name... it doent work... even author-uid doent seem to be working either

So,

either I am wrong with the auto title thing altogether... OR

beside this I need to change some template/theme file too...

Michelle, please help

Submitted by Kristen on

You could add a patch file instead of editing the guestbook.module directly. If the guestbook needs to be updated, the patch will continue to work unless those particular lines are changed, in which case you would need to go in and figure out a new edit anyway.

Submitted by Admin on

I've been pretty bogged down with trying to get the event module usable and haven't checked back here. I see there's a bunch more comments. I will try and get in and answer them soon.

Michelle

Submitted by Anonymous on

great snippet!

Submitted by Stevenls on

Hey all,

I am just learning this and using this tutorial to build the page then tear it apart and fiddle with the mechanics to understand it all.. with that I am sure to get stuck along the way.

I am stuck here, though in looking at the following steps I can keep going but I don't want to skip anything;

Step 3 - Avoiding naming collisions
DON'T DO THIS STEP!!! If you've already done it, undo it. It breaks usernode!

To avoid having your usernode and nodeprofiles having the same titles, edit the usernode content type (?q=admin/content/types/usernode) and change the autotitle token to something else. I used "Usernode of [author-name]". The user will never see this, but it's nice to make it clear to admins which is which.

I am just not sure where to go with this, I went to Administer, content, types but then couldn't see what I had to do based on the above text. Would someone be able to just dot point what I should be doing there or see at the end of the step.

Many thanks to anyone who can help.

S.

Submitted by Admin on

Isn't "DON'T DO THIS STEP!!!" fairly clear? I'll be taking that step out when I go through all the comments and update the tutorial. I found out after the fact that usernode and auto node titles are not compatible so put that warning in.

Michelle

Submitted by stevenls on

You know I read that as Don't do it if you have already done it... that will learn me to skip over a heading to the crunch of what I should be doing.

Apologies, will let you get back to the posts of people who are actually paying attention!! :)

S.

Submitted by stevenls on

Hey,

I sent you a pvt message (to super admin) from the test site. Would you be able to look at it and contact me when you can in relation to it.

Thanks.

S.

Submitted by CAT4MBA on

Seems Michelle is busy
Any body can suggest what cld have gone wrong
I am desperately trying to make things work properly

Submitted by Admin on

Sorry if I sounded snippy in my answer... I really need to take some time to go over the comments and clean up this tutorial. Just have a lot on my plate right now.

Michelle

Submitted by Admin on

...

Submitted by Admin on

I've been lax in getting to these comments. I'm trying to get my site done before the baby comes so my computer time has been directed towards that. If you could email me a link to your site, that might help me help you. It's hard to guess from your description what might have gone wrong.

Michelle

Submitted by Admin on

You're right, I should have done it as a patch. I just learned how to make a patch a couple days ago and it's not too hard. I'll do that when I go back over all this and incorporate the comments.

Thanks,

Michelle

Submitted by Admin on

I had a feeling it would be something with form alter. I've learned more dev stuff since I wrote this tutorial so there's some things I can make better. Thanks for the snippit. I'll add it in my cleanup.

Michelle

Submitted by Admin on

Sorry, I've never looked at that. I guess I figure if people want their first name to be used everywhere they'll use it as their username.

Michelle

Submitted by Admin on

Auto node title is not related to showing the first name instead of username. It's only there to give the node a title. Don't use it on usernodes; it breaks them.

Michelle

Submitted by Admin on

The embedded user tracker is a view. To change the number of entries shown, edit the view itself.

Michelle

Submitted by Admin on

I've never used this theme but I downloaded it and took a quick look. Replacing the entire function with this should work:


function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {

if (arg(0) == 'user') {
$vars['tabs'] = str_replace('Edit', 'Edit Account', $vars['tabs']);
}

if ($secondary = menu_secondary_local_tasks()) {
$output = '';
$output .= "

    \n". $secondary ."

\n";
$vars['tabs2'] = $output;
}

// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
return $vars;
}
return array();
}

Michelle

Submitted by droople on

Please supply a donate button, so maybe we can drop a fe dollars and pounds, if u don`t mind

thanks

Submitted by stevenls on

Another pvt message, my reply to your email bounced.

ta

S

Submitted by Admin on

I don't see a private message over there other than your first one. Try sending the email again. I don't know why it would have bounced unless it accidentally got marked as spam.

Michelle

Submitted by Admin on

I'm not doing this for money. If you want to repay it, go help someone else who needs help with Drupal. Everything I learned has been from learning from those who came before me.

Michelle

Submitted by Emanuel on

I can't get the "buddylist" section of the full featured profile to show up. Even when you have buddies, it says "user has no buddies"
I get this when I go to the page url:

* user warning: Query was empty query: in /home/developw/public_html/includes/database.mysql.inc on line 172.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 10' at line 1 query: LIMIT 0, 10 in /home/developw/public_html/includes/database.mysql.inc on line 172.

User has no buddies

Submitted by Admin on

The only thing I'm doing is adding


if (arg(0) == 'user') {
$vars['tabs'] = str_replace('Edit', 'Edit Account', $vars['tabs']);
}

into code that's already there and there's nothing in that code that would break it. Can you paste the entire template.php you're using, start to finish?

Michellle

Submitted by Admin on

The first page you linked to is the nodeprofile node. The second is the user account view. Looking at the two, it looks as though you skipped step 4 and didn't embed the nodeprofile into the account view page. What you're seeing is what the nodeprofile module does by default.

Michelle

Submitted by Admin on

If you go to the view's page and look at it non-embedded, does it work then?

Michelle

Submitted by cat4mba on

Thanks Michelle for the reply
I don’t think I have missed any steps but I ll be go though all the steps(including step4) once again and let you know what happen
Being a technical naive I am not that confident of what I have done

Submitted by Admin on

That's what I get for answering comments when I first wake up... I'm looking at that page again and it's not the default nodeprofile view. The tabs showing is what fooled me. Looking closer, I see that it's printing the gender, which is a cck field but not the others. And it doesn't have the other stuff on the page like it normally would in the default view. Definitely something screwy, but it's hard for me to tell what. If it happens again on the second run through, let me know and I'll try and see if I can figure it out.

It's definitely something wrong in step 4, since the nodeprofile node looks fine, but it doesn't look skipped so much as messed up.

Sorry for misleading you,

Michelle

Submitted by Anonymous on

Everything looks good now.
Yes the problem was with template file
Thanks again

Submitted by Admin on

Glad you got it working.

Michelle

Submitted by Emanuel on

Ok, I got rid of the warning, and even got the default display picture to display.
I think the problem was there was no default picture, and there was no user picture...which brings me to another problem.
For the CCk fields, I added them manually and included a field_picture, which is displayed as the user picture. BUt it appears this is not being recorded as the user picture, so when a user appears on a buddylist or when placing a comment, the default picture is used.

How do I get the picture uploaded to list as the user picture and thus show correctly in buddylists and comments.

On a side note (for anyone that might want to do it), I got a gallery to work (just all the pictures the user has uploaded). Here is the view code: $view = new stdClass();
$view->name = 'Images_Published';
$view->description = '';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '';
$view->page_header_format = '3';
$view->page_footer = '';
$view->page_footer_format = '3';
$view->page_empty = '';
$view->page_empty_format = '3';
$view->page_type = 'bonus_grid';
$view->url = '';
$view->use_pager = TRUE;
$view->nodes_per_page = '12';
$view->block = TRUE;
$view->block_title = '';
$view->block_header = '';
$view->block_header_format = '3';
$view->block_footer = '';
$view->block_footer_format = '3';
$view->block_empty = '';
$view->block_empty_format = '3';
$view->block_type = 'bonus_grid';
$view->nodes_per_block = '6';
$view->block_more = TRUE;
$view->block_use_page_header = FALSE;
$view->block_use_page_footer = FALSE;
$view->block_use_page_empty = FALSE;
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
array (
'type' => 'uid',
'argdefault' => '1',
'title' => '',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
);
$view->field = array (
array (
'tablename' => 'node',
'field' => 'body',
'label' => '',
'handler' => 'views_handler_field_body',
),
array (
'tablename' => 'image',
'field' => 'nid',
'label' => '',
'handler' => 'image_views_handler_image_img_link',
'options' => 'category',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'image',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, image);
$views[$view->name] = $view;

and this goes in the contemplate field: (style and place as desired)

Gallery:
<?php
$view = views_get_view('Images_Published');
print views_build_view('embed', $view, array($profileuser->uid), false, false);
?>

Submitted by Emanuel on

You must go to Site Congifuration / Image then add a type called "category" - mine is set at 64 x 64 since any larger would look odd on my page.

Either that or change the line 'options' => 'category', - replacing category with whatever the name of your image size is going to be (thumnail, preview etc)

Submitted by droople on

I got it, I wasn't adding that piece of code in the right place.

Instead of pasting that piece to the seconadry links code, I was pasting the whole snippet at the bottom of the template.php

THANKS, YOU rock

Submitted by droople on

instead of using taxonomy terms, How do I code, so that some fields, upon clickin on them show all other users with similar entries on their profiles?

Thank you

PS:

Any hint on the gallery section

cheers

Submitted by Admin on

I hate to be mean, but I'm going to draw a support line here because I'm getting overloaded with the questions on this tutorial and this would take me having to actually go figure out how to do it before I could answer you. I suggest making a forum post to see if anyone has an idea.

As to the gallery, I haven't started on it, yet, but there is this comment that I haven't had a chance to investigate: http://shellmultimedia.com/node/5#comment-122 .

Michelle

Submitted by Kristen on

I'm having trouble getting the guestbook to show at all. On the guestbook module, they say you can use this code in your template:

<?php
if (module_exists('guestbook')) {
if(!$user->guestbook_status){ // guestbook_status seems to store 0 for enabled and 1 for disabled
print module_invoke('guestbook', 'page', $user->uid);
}
}
?>
I put this in the phptemplate_guestbook function, and it shows an entire page, and says page not found. I know there is a way to tweak it, but I don't know enough yet. Does anyone else know how to make this work?

Submitted by droople on

#2 After editing or updating

Use the "node_go_to module" you can set paths to redirect to after creating, editing or deleting node

Submitted by Kristen on

I solved it. I just missed one of the steps. I didn't originally have the guestbook option. I added it later and missed a step. Sorry! :)

Submitted by Admin on

I'm rather slow at answering these comments so it's always nice to come back and find them solved already. :)

Michelle

Submitted by Admin on

There's actually another solution buried in these comments that doesn't require another module. I do intend to revamp the tutorial based on all the feedback but I've got a lot of projects going at once and haven't gotten to that, yet.

Thanks,

Michelle

Submitted by greenbuilder on

Hi,

I used this snippet but found that it was causing some weirdness when users were creating new accounts. It was redirecting before the new user email was sent and also didn't display the proper messages to the user who just created the account. I added a simple check if user is logged in and it works great.

My code is now:

<?php
function nodeprofile_bonus_form_alter($form_id, &$form) {
if ($form_id == 'uprofile_node_form') {
$form['#submit']['nodeprofile_bonus_node_form_submit'] = array();
}
}

function nodeprofile_bonus_node_form_submit() {
global $user;
if ($user->uid) {
drupal_goto('user/' . arg(1));
}
}
?>

Submitted by Admin on

I do still plan on rolling these fixes into the tutorial... Just been busy with other projects for a while.

Michelle

Submitted by sebi_tl@drupal.org on

heyhey everyone...

thanks for this great tutorial, this is the stuff that brings the community forward! i built my site-profiles exactly like your's and what really bothered me was the image gallery not working... so i spent some time on integrating the image.module in the profile. my solution provides the user's latest 5 uploaded images and a link to an extra view with all of the users pics... maybe this is helpful for somebody...

step 1 - create a view

go to /admin/build/views/import

and paste the following code:


$view = new stdClass();
$view->name = 'images_of_user';
$view->description = 'The User\'s uploaded images';
$view->access = array (
);
$view->view_args_php = '';
$view->page = TRUE;
$view->page_title = '';
$view->page_header = '';
$view->page_header_format = '1';
$view->page_footer = '';
$view->page_footer_format = '1';
$view->page_empty = 'This user has not uploaded any images.';
$view->page_empty_format = '1';
$view->page_type = 'list';
$view->url = 'userpics';
$view->use_pager = TRUE;
$view->nodes_per_page = '20';
$view->sort = array (
array (
'tablename' => 'node',
'field' => 'created',
'sortorder' => 'DESC',
'options' => 'normal',
),
);
$view->argument = array (
array (
'type' => 'uid',
'argdefault' => '7',
'title' => '',
'options' => '',
'wildcard' => '',
'wildcard_substitution' => '',
),
);
$view->field = array (
array (
'tablename' => 'image',
'field' => 'nid',
'label' => '',
'handler' => 'image_views_handler_image_img_link',
'options' => 'thumbnail',
),
array (
'tablename' => 'node',
'field' => 'title',
'label' => '',
'handler' => 'views_handler_field_nodelink',
'options' => 'link',
),
);
$view->filter = array (
array (
'tablename' => 'node',
'field' => 'type',
'operator' => 'OR',
'options' => '',
'value' => array (
0 => 'image',
),
),
);
$view->exposed_filter = array (
);
$view->requires = array(node, image);
$views[$view->name] = $view;

click submit and save the view. this provides a view of the user's uploading images in descending order. you can sure adjust some things to your needs, like changing the empty text or the url alias... mine goes to /userpics/$arg

step 2 - adjust your content template

go to /admin/content/templates/uprofile
in the body-section, change the following

Gallery:
The Gallery part of your profile will be available sometime in the future.

to

Gallery:
<?php
$view = views_get_view('images_of_user');
$limit = 5; //this sets the number of displayed images
print views_build_view('embed', $view, array($profileuser->uid), false, $limit);
?>

uid ?>">...click here to view all of <?php print $profileuser->name ?>'s pictures

step 3 - adjusting template.php

i did this following steps with the great views theme wizard, so this code is not, i repeat NOT written by me!

nonetheless... this goes to your template.php (in your theme-folder, i'm sure you know that):


function phptemplate_views_view_list_images_of_user($view, $nodes, $type) {
$fields = _views_get_fields();

$taken = array();

// Set up the fields in nicely named chunks.
foreach ($view->field as $id => $field) {
$field_name = $field['field'];
if (isset($taken[$field_name])) {
$field_name = $field['queryname'];
}
$taken[$field_name] = true;
$field_names[$id] = $field_name;
}

// Set up some variables that won't change.
$base_vars = array(
'view' => $view,
'view_type' => $type,
);

foreach ($nodes as $i => $node) {
$vars = $base_vars;
$vars['node'] = $node;
$vars['count'] = $i;
$vars['stripe'] = $i % 2 ? 'even' : 'odd';
foreach ($view->field as $id => $field) {
$name = $field_names[$id];
$vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
if (isset($field['label'])) {
$vars[$name . '_label'] = $field['label'];
}
}
$items[] = _phptemplate_callback('views-list-images_of_user', $vars);
}
if ($items) {
return theme('item_list', $items);
}
}

step 4 - create views-list-images_of_user.tpl.php in your theme-folder

...and paste this:


<?php
/**
* views template to output one 'row' of a view.
* This code was generated by the views theming wizard
* Date: Do, 06/07/2007 - 23:13
* View: images_of_user
*
* Variables available:
* $view -- the entire view object. Important parts of this object are
* images_of_user, .
* $view_type -- The type of the view. Probably 'page' or 'block' but could
* also be 'embed' or other string passed in from a custom view creator.
* $node -- the raw data. This is not a real node object, but will contain
* the nid as well as other support fields that might be necessary.
* $count -- the current row in the view (not TOTAL but for this page) starting
* from 0.
* $stripe -- 'odd' or 'even', alternating. * $nid --
* $nid_label -- The assigned label for $nid
* $title -- Display the title of the node.
* $title_label -- The assigned label for $title
*
* This function goes in your views-list-images_of_user.tpl.php file
*/

?>

<?php print $nid_label ?>

<?php print $nid?>

<?php print $title_label ?>

<?php print $title?>

step 5 - adjust the styling

the following stuff is really ugly code with hardcoded pixels and stuff! i recommend you style your view for yourself!
i just hurried this down, so it's is just to get you started, i won't leave it like this for myself...
open style.css from your theme folder and add the following:


.node .content #user-gallery li{
width:100px;
float:left;
text-align:center;
text-decoration: none;
border: 1px solid black;
padding: 10px;
margin: 5px 10px 10px 5px;
}

.node .content #user-gallery li .view-data-nid{
height:100px;
}

.node .content #user-gallery .view-data-title {
margin-top:5px;
width:100%;
text-align:center;
}

.view-images-of-user li {
height:120px;
float:left;
text-align:center;
}

i hope i didn't forget anything, would be great if someone more advanced could take a look over it ;)

sleep well

sebi

//edit: damn... i just saw that there's a solution very similar to the one i posted... so... forget about it ;)

Submitted by Admin on

It's my fault for not getting around to incorporating the comments into the tutorial yet. I keep meaning to but other projects get in the way. I appreciate you posting this. I'll at least go in to the tut and make a link to these two comments a little later this morning. Gotta run now.

Michelle

Submitted by thom on

This should also work, more or less same solution:

<?php
function nodeprofile_bonus_form_alter($form_id, &$form) {
if ($form_id == 'uprofile_node_form' && arg(0) == 'user' && is_numeric(arg(1))) {
$form['#redirect'] = 'user/' . arg(1);
}
}
?>

Submitted by Anonymous on

Hey Michelle,

I did exactly what you described in your tutorial, but when I create the content type "User Profile" I can't see the tab "node profile".
In your description you wrote that you needed to copy the bonus files into the nodeprofile module, i did this.

I also used the versions that you prescribed.

I'm totally stuck, could you please help me?

Thanks,

Peter

Submitted by Admin on

That tab isn't anything I added. It comes with nodeprofile. Couple things...

1) Double check that you have the latest nodeprofile module as it's new in the April 29th version.
2) Make sure you checked the box on your content type for it to be a node profile.

Michelle

Submitted by Saljustsal on

Hello,

I just went through the tutorial and it mostly worked for me. However one issue I've had is when the "edit profile" tab is clicked, rather than taking me directly to the user profile, it gives me a list of content that I have permission to edit/create (for example I get a choice of creating a new forum topic or editing the user profile). If I login with a user that has a lot more permissions, then I get a list of all the different kinds of content I can create/edit, one of them being the user profile node.

Submitted by Saljustsal on

Also, when I go to actually edit the user profile page, I receive the error "You can't create more nodes of this type for this user."

It seems as if it is actually trying to create new content rather than edit old.

Submitted by Saljustsal on

Okay, found the error. I started off using "userprofile" as a name instead of "uprofile". The file nodeprofile_bonus.module needs to be changed if you use anything other than "uprofile". Once I made those changes the edit profile tab pointed in the right direction.

I wanted to change my "userprofile" type to "uprofile", so I wouldn't have to worry about missing any other revision, but when I did that I couldn't see profiles, they were blank. Even after verifying that the access permissions were correct, they were still blank, however the edit tabs still worked fine. With a admin account I could see the info, but the templates seemed to be missing (no buddy's list, no guestbook, no neat layout, etc.) So I changed it back to "userprofile" and things are fine again.

Submitted by Casey on

I can not seem to get node_profile_bonus to appear in the module menu....

I have uploaded nodeprofile_bonus.module and nodeprofile_bonus.info to /modules/nodeprofile/

Any ideas ?

Submitted by Casey on

btw, I did run update.php to refresh the module and chose nodeprofile with success

Submitted by Eike on

Thanks for the tutorial! And with the Node to go it's even better!

Submitted by Val on

I observed clicking on the 'Edit profile' will break the template under Internet Explorer.

The problem is in the node-uprofile-edit.tpl.php file in your template directory.

Edit this file and towards the top of the page replace:
print drupal_render($form['field_about_me']['0']['value']);

with

print 'About me';
print drupal_render($form['field_about_me']['0']['value']);
print '';

This will put the form in a container which will prevent the right column being displayed under the body.
Hope this helps.

Submitted by Val on

Sorry, copied the wrong code above. The correct replacement code for the broken IE template is:

print 'About me';
print drupal_render($form['field_about_me']['0']['value']);
print '';

These 3 lines will replace the original:
print drupal_render($form['field_about_me']['0']['value']);

Submitted by Val on

Sorry, copied the wrong code above. The correct replacement code for the broken IE template is:


print 'About me';
print drupal_render($form['field_about_me']['0']['value']);
print '';

These 3 lines will replace the original:

print drupal_render($form['field_about_me']['0']['value']);

Submitted by jubei on

This tutorial is amazing. Exactly what I was looking for...thank you.

Everything seems to be working well except I'm not sure exactly what you mean by:

- If you are not using clean URLs, you will have to adjust the links for the taxonomy terms.

I'm not using clean URLs but I'm not sure where to adjust the links for the taxonomy terms that you are referring to. A little more guidance on this would be great.

Thanks

Submitted by gray on

How did you fix this? I'm having the same problem since adding this snippet to my template.php file.

Submitted by Admin on

Ok, I've gone through all the comments and made notes on things that need to be updated / fixed in the tutorial. These are rough notes for myself so may not make perfect sense, but I'm pasting them here for people who are just starting the tutorial so they can see things that need fixing.

Michelle

***Views errors:
Contemplate file: print views_build_view('embed', $view, array(strval($profileuser->uid)), false, false);

*** Auto node title
Check out latest version of usernode to see if it's ok

*** Redirect after edit profile
Node to go or http://shellmultimedia.com/node/5#comment-132

*** Use l() for taxonomy terms
l($item->name, "taxonomy/term/" . $item->tid)
This answsers http://shellmultimedia.com/node/5#comment-152

*** Fix uprofile edit form
The trick to hide extra fields causes them to be unpublished. Find the proper way to do it with unset

*** Hardcoded uprofile
Find the places where the name uprofile is hardcoded and avoid it or document it

*** More clarification on merging with template.php for replace Edit link
http://shellmultimedia.com/node/5#comment-153

*** Themes in subdirs
See http://shellmultimedia.com/node/5#comment-80

*** Patch file for guestbook changes

*** Buddylist errors if no default picture and no user picture

*** User image gallery
http://shellmultimedia.com/node/5#comment-122
http://shellmultimedia.com/node/5#comment-138

*** Fix edit profile in IE
http://shellmultimedia.com/node/5#comment-151

Submitted by gray on

Oh I think notepad messed up the file. Works now by replacing w/ backup and adding code using real php editor.

Submitted by sevenahm on

Thanks, Michelle for posting this. I implemented this on a social networking site I am developing and it seems to work pretty well. There are a few issues:

1. When I go to node userlisting i see a search selection and a list of user teasers. The full profile is viewable by clicking on the userid. That's great, but when I go to My Account, I only see the teaser in the view mode and there is no link to see the full profile. Did I leave something out?

2. I am thinking about installing the Adsense module which depends on profile which I have disabled. Will it mess things up if I enable profile? Or do you think there is a way to use Adsense with the custom user profile. I am concerned about namespace and other possible collisions/conflicts if I turn on the profile module. I don't quite understand all the architecture involved.

3. I see that people are finding ways to use the image module but shouldn't we be using a cck image field on the profile? It seems more consistent, plus lullabot's "deprecated" podcast ( http://www.lullabot.com/audiocast/drupal_podcast_no_38_deprecated ) seems to indicate we should steer away from the image module if possible when building new sites.

For items 2 & 3 I am just asking for some guidance not necessarily the ultimate solution on a silver platter.

Thanks again for your hard work and your sharing.

Edwin

Submitted by Admin on

1) Well, that's not normal. I can't think off the top of my head what would cause it, though. :(

2) Fago has said that profile and nodeprofile can both be on the same site so there shouldn't be an issue.

3) That podcast was a lot of FUD. It brought up some good things to think about but should not be taken literally. Image module isn't deprecated and, in fact, after just discussing it with the maintainer and some others in IRC, I've decided that I'm going to use it on my site. So when I update this tutorial to add in the gallery part it will likely be some version of image.

Michelle

Submitted by Angrywombat on

I've run through the tutorial several times but I cannot get this to work properly. The guestbook is never shown on the user's profile. I have it set so that users don't input anything but their email address and user upon registration. When you try to edit your profile information, you get an error about a node for that user already existing. So I then enable all the fields and try again. However, when I submit that information, the user's profile shown is just a simple HTML table with no real information on it and it breaks drupal (all the menus and such at not there, just the HTML table). I think this is because a template is missing, but I know there aren't any missing and I've followed all the theming instructions. Any idea what would cause this?

Submitted by Rachel on

Wonderful tutorial. I have had a lot of fun working though it and reading all the comments.

A question about enhancing: I have created and tested a pageroute to add to a content type in addition to uprofile. I tried to replace the "edit-profile" link (the tab that was created by "function nodeprofile_bonus_menu") with the path nodeprofile, the name of my pageroute, unsuccessfully. I am not a champion of PHP, but it seemed this should be a fairly straightforward tweak and so I thought I'd see if it is something you are familiar with, though clearly you are very busy with a growing family :)

Submitted by Admin on

I haven't looked at pageroute at all, so I have no idea about it. You might want to try the Drupal forums for this question as it's not really specific to this tutorial.

Michelle

Submitted by Admin on

I keep coming back to this comment hoping to be able to give you an answer, but I don't have one. I've never been very good at troubleshooting blind. I know the tutorial works, so all I can suggest is running through it again to see if you missed something.

Michelle

Submitted by Val Juhasz on

Hi Michelle,

Great tutorial, works great. I did it all the way trough, no errors. Everything is fine, however my buddylist section is empty, tells me I have no buddies. The enabled buddylist sidebar box shows buddies, but the profile form not.

Any idea what might have been wrong? The buddylist view imported well, and made the correction in the filter so it shows usernodes.

Thanks,
Val

Submitted by Val on

Found the problem. By mistake I set the 'uprofile' content type to be 'Unpublished' by default, and all buddies got filtered out by the view.

Submitted by NeoID on

First of all thanks for this tutorial it helps me a lot, as I'm trying to port my site to Drupal :)
Anyway, I've attached a image that shows my current problem...
http://img340.imageshack.us/img340/3543/untitledwk3.jpg
As you may see there is a "frame" around the profile and the avatar got outputted twice. Do you know which files I have to edit? I can't find the problem in any of the theme-files and I'm not too familiar with Views/CCK just yet...

I'm sorry to ask so many questions, but there is also another thing that is a little bit unclear to me...
About the "known issues" you mentioned, is there a "fix" for the following?:
- User listing view sends you to the nodeprofile node (while the redirect after editing the profile is fixed)

- Admin created accounts don't work right, not really important to me, but if anyone has a solution it would be nice.. :)

Again, thanks alot for your help :)

Submitted by strangeways on

Thank you for the great tutorial. I do have one question, however. I want to make the registration form simpler than the full profile. Is there a way to only show some of the fields in the registration process? So for example, the user would fill in Full Name and Country when registering, but could also fill City, Occupation, or whatever else once they've registered and are editing their profile. I noticed that the core profile module has that ability, but I'd much rather use your technique so that I can use CCK fields and taxonomies in the user profile.

Thanks again for this post, it has been a terrific help!

Submitted by Admin on

The nodeprofile module does not offer this ability. A few ideas:

* File a feature request on nodeprofile
* Create a separate node profile content type for the reg screen
* Use hook_form_alter to remove some fields when the node profile is on the reg screen

I don't have specific how to's on these but am offering them as suggestions for ways to do it for you to further research.

Michelle

Submitted by Admin on

The first one looks like you didn't do step 4.

I haven't looked into redirecting from the user listing. The reason it sends you to the nodeprofile node is that the listing is just a view of nodeprofile nodes. You can probably get around that by theming the view.

TBH, I don't remember anymore what doesn't work about admin created accounts... I moved on to other parts of my site after finishing the profiles so it's not fresh in my mind anymore.

Michelle

Submitted by NeoID on

Thanks, it's great that people take there time to give others a kick start....
Have a nice day and again thanks for your help...

Submitted by Lucas on

Hi Michelle-

THANK YOU SO MUCH for this tutorial. It worked like a charm and I am busy customizing it.

One problem I have run into that has driven be bonkers for the past few nights, surrounds adding new groups to the userprofile page. I has thought all was well because it showed up correctly on my admin profile, but on my test login, the fields did not turn up when I click on "edit profile" - all of the other groups that you had in your build show up fine. I couldn't find any type of permissions for this, so I thought maybe I had to fiddle with the template, but then I realized that I could see the custom group fields when I edited my admin account, so I got lost again....

Any thoughts?

BTW- you rock my world.

Submitted by strangeways on

Thank you for the suggestions. I'm now using hook_form_alter in a custom module to remove the fields from the form on the registration page.

Submitted by Admin on

By adding groups, you mean adding more cck fields to the nodeprofile and putting them in a group? I'm going to assume that's what you mean...

In node-uprofile-edit.tpl.php you should see code like:

print drupal_render($form['group_stats']);

You'll need to add another line like that with the name of your group. This is what prints out the form fields for the group.

Michelle

Submitted by jesuspepsi on

This was very helpful in performing one part of a feature I have to implement to the page I listed as my homepage -- forcing a user at registration to give contact information for player registration in a charity golf outing. Any tips on getting the next step for them to choose a payment method (mail-in or paypal), determine from their choice on the reg page how much to charge ($100 for fee + $40 for shirt if selected or $0 if none), and have a place to view all of that information? Any help would be much appreciated.

Submitted by MamasDiner on

Thank you Michelle for such a great tutorial! I was going along perfectly after modifying some aspects very carefully, then this error showed up.

Anyone else come across this error?

warning: Invalid argument supplied for foreach() in /home/twomarke/public_html/mydomain/modules/cck/fieldgroup.module on line 395.

If so, any help on fixing it would be greatly appreciated as its showing on my frontpage while I'm not logged in and also when I am.

Thanks!

Heather

Pages