Drupal How To: Content Profile Basics

March 22nd, 2009 · 15 Comments

A Good Profile Is Key

A Good Profile Is Key

In Drupal complex tasks can be very easy.  Sadly many times simple tasks can be complex.  Even more often, to make a complex task simple, you have to make a simple task complex first.  Such is the case with the content profile moduleNote, this example uses Drupal 6.

Why Do I Want Content Profile?

The content profile module allows you to define a content type to represent your users profiles.  This allows a tremendous amount of customization without dealing with code.  You can use the CCK to define very complex node types to represent your users profiles.  We will get to doing that later, unfortunately getting to the point where your content profiles look like…well…profiles takes a bit of doing.  Be aware that there are many ways to do Profiles in Drupal and this is just one option, be sure you need this flexibility before you start down this path.

Setting Up Content Profile

First of course you have to install the content profile module and the CCK.  You’re on your way now.  Once the module is installed it will have created a profile content type.   Great.  Unfortunately you have a bunch of steps to go before it is usable at all.  The first thing we need to do is designate that it’s a profile type by going to Administer->Content Types->Profile->Edit. In the last section, “Content Profile,” you will find a checkbox that reads “Use this content type as a content profile for users.”

Unfortunately of course a normal user can’t edit this content type, so go to Administer->User Management->Permissions and give your logged in users permissions to create and edit thier own Profile content.  You do not want them to be able to edit other people’s content so do not give them the “edit any profile content” permission.

So you’d think we’d be close to done now, but if you now go and try to edit your profile you’ll see there’s a required title field.  Even more annoyingly the only way to get rid of it is to add another module, the Automatic Node Titles module.  Once you install this you go to the profile content type (Administer->Content Types->Profile->Edit again) and you’ll see a section at the top called “Automatic Title Generation.”  Open that and set the option to “Automatically generate the title and hide the title field.”  I don’t see any reason to care what the title will be since it will be used inside another page anyway so I don’t worry about setting any other options.

Now we’ve got it to where it’s reasonable to edit.  You can go fill out the body field (as if it were a bio for example) and save and you’ll see it on your profile.  Unfortunately you’ll also see a bloody “Submitted by X on …” line at the top of it.   Great!  To get rid of that go to Themes->Global Settings and in the upper right hand corner you’ll see a list of content types inside a box labeled “Display post information on.”  Remove Profile and voila!  We’ve managed to make an absolutely boring profile in Drupal with just 10 semi-easy steps.

Now you might be wondering why we went through all that trouble just to get a really bland profile that looks decent.  The reason is because now that we’ve gotten a content profile set up and looking right, we can do the very complex task of making cool custom profiles very easily.  We’ll address that later, but this should at least get you through the frustrating act of getting the initial profile set up.  Let me know if anything needs clarification or if you disagree with anything.

Photo Credit: misteraitch

Categories: Applied Use

Related Posts:

15 responses so far ↓

  • wza | Mar 26, 2009 at 1:37 pm

    so how can u make a user edit his/her own profile info? and can u generate a menu link for the users to do so?

  • Brad | Mar 27, 2009 at 1:44 pm

    wza,

    The easiest way I think is to use the “me” module:

    Me Module

    Which will create menu items for the currently logged in user.

  • josh | Apr 8, 2009 at 4:33 am

    Interesting read. Pretty straight-forward and should help me get started on better profiles.
    Looking forward to your next post about “making cool custom profiles.”

  • Rick | Apr 29, 2009 at 1:29 pm

    After setting this up, my content profile does not show up on the main user account page, it only shows when the user clicks edit and then there is a link to edit the content profile. Is there a way for this to show up on the main user page, am I just missing a setting somewhere? I have it set on content profile page where it says “User page display style” I have set “Display the full content”. Thanks in advance for any advice.

  • Borik | May 5, 2009 at 1:10 pm

    So how can u make a user edit his/her own profile info?

    When i click on edit link i don’t see any of the new fields,
    it shows default Edit Screen, i was hoping to see all the fields.

    Thank you

  • Brad | May 5, 2009 at 2:23 pm

    Both of these questions seem to be relating to the same fact. There is a tab under their profile where they can edit the additional fields, however I agree that it would be nice to have them in the first tab. I will check on how to do that.

  • Andy J | Jun 13, 2009 at 6:14 pm

    Thanks this was useful info. Any plans to write the follow up article? Thanks

  • Brad | Jun 13, 2009 at 9:00 pm

    Andy,

    Yeah I have a few drafts of things I keep meaning to put up on here. I will make a special effort since I’ve been such a slacker.

  • Kenny S. | Jul 2, 2009 at 5:57 pm

    Great starter article. I was just browsing the web for content profile information since I have a special use case and wanted to throw in a suggestion if I may.

    I prefer to set the Automatic Node Title on my Content Profiles simply because if you don’t, you end up with a ton of nodes in your content list that have the title: “profile” or whatever you have named the content type.

    Typically what I do is set the title to be [author-name] from the Token module. This makes life easier because a username has to be unique. The only rub is if in your in a scenario where the usernames can be changed by the user. In which case, you would want a quick hook_user in a custom module to change the title as the username is changed.

    Thought I’d toss that in. Great site!

  • Brad | Jul 2, 2009 at 6:05 pm

    Kenny,

    That’s an excellent suggestion. I don’t remember actively doing that but it seems to have gotten set up on mine. Thanks for the pointer, I will walk through a setup again to see how it wound up that way and update the post.

  • Sven Aarts | Oct 26, 2009 at 5:58 am

    Tnx for your post.
    I had some problems with custom cck fields not showing up on the profile page but I found out you can configure them to show up on the permissions page.

  • Darrin Southern | Jan 10, 2010 at 2:12 am

    “The reason is because now that we’ve gotten a content profile set up and looking right, we can do the very complex task of making cool custom profiles very easily. We’ll address that later . . .”

    I’d be very interested in seeing a blog post that explains how to do this part.

    Is it ‘later’ yet :)

    Thanks in advance,

  • Jeff Kenner | Jan 12, 2010 at 3:03 am

    Thanks for this easy-to-follow guide. Like everyone else, I can’t wait for the “cool custom profiles” part.

    Cheers!

  • Derek | Feb 15, 2010 at 10:01 pm

    Great post. I had removed Content Profile because I didn’t know about the Automatic Node Title module, but after reading this I put it back on and got everything working exactly the way I wanted. Thanks!

  • Jeremy | Feb 23, 2010 at 12:26 pm

    Hi, I’m wondering if you ever got around to doing the theming article you talked about. I’m really interested in finding an easy way to theme the user profile page for content profile. Thanks.

Leave a Comment