Extending the content profile module - docs?
Hi all,
I would like to add some fields to this node type with a custom module, rather than using CCK. CCK builds things in the database, which will make it difficult for me to multisite my web app. I'd rather write code! (Correct me if I'm wrong here.)
One of the major benefits for me is that now I can associate taxonomy with my users! Very cool.
Anyway, is there documentation or guidance around how this module works, so I can read up on it? I don't see any new database tables that were created because of this module... so it's a bit of a mystery.
Please point me in the right direction!
Thanks,
Tom


.
Content profile just associates a node type with a user for use as a profile. If you want to add fields in code, then you need to read the FAPI docs for creating fields for nodes in general; it's not content profile specific.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
I was beginning to suspect...
Hi Michelle,
Thanks for the reply. I'm new to Drupal so it's counter-intuitive to me that I can add a new node type and Drupal will just figure out the rest. New paradigm! That's cool. Thanks for your help.
Tom
Well
It depends what you mean by "the rest". You need to check the box to let content profile know that this node type is to fall under its control. And then content profile handles connecting it to the user.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
Almost there...
Hi Michelle,
I created a module to add a node type called "gprofile" that includes custom fields like first name and last name.
However, if I change the "type" string in content_profile to match, it says the name is already taken. So I think I'm still missing something. I figured I would have to make the names match, but content_profile seems to want something else - true?
Tom
Got it!
OK I'm a dork - I found the check box. :)
Thanks for all your help Michelle.
Tom
Doesn't see my custom-module-defined fields...
Aha, it only seems to like CCK fields. It doesn't find the fields I created myself. That doesn't suit my needs at all, because I am trying hard to avoid CCK. (Because if I used it, all those database-defined fields would not be available to other sites in a multisite environment).
So is it possible to have content_profile recognize my custom-module-defined fields, or am I barking up the wrong tree here?
No idea
Making fields in code is so 4.6... LOL! I wouldn't dream of not using CCK. It's far easier to import a node type export into multiple sites than write that all in code.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
Cleverly eluding the question...
Hi Michelle,
Doesn't it depend on how many times you're going to have to multisite? I'm planning on hundreds of sites, so adding a step to my site replication sounds like a nightmare.
But you didn't really say - does content profile have any way to recognize my fields? Or do I have to figure out how to hand-code all this integration with the user table/objects?
T
Eluding?
How exactly is saying I have no idea eluding the question? That's a pretty clear answer, I think. You're trying to do something that 95% of Drupal users, including myself, have never tried. You can try asking in the content profile issue queue but my guess is you're pretty much on your own if you insist on hand coding all the fields.
Michelle
See my Drupal articles and tutorials or come check out the Coulee Region
How it seems to work
I'm surprised about this, but apparently content_profile works out of the box with nodes in the schema in the module.install file. So you can mix and match CCK fields with fields you add to your node type in other ways. WOW!
Now that I understand a bit more how the UI of content_profile works, I realize that this thread could have been avoided. :)
Tom
Sorry - missed it
Hi Michelle,
Sorry - I missed your actual subject line where you said "no idea." :)
OK here I go, reading code.
Thanks,
Tom
Doesn't depend on the number of replications
Step 1. Configure your base site
Step 2. Back up codebase and db of your base site.
Step 3. Replicate your site once or one thousand times.
If you have a standard config that you know will be your starting point, then you can use the db dump to deliver that config ad infinitum.
Cheers,
Bill
FunnyMonkey
Click. Connect. Learn.
Using Drupal in Education
Maintenance concern...
Hi Bill,
True, I could create a base database for a starting point. However, I want to have hundreds of sites up and maintain them all as well, and since they all run off a single codebase, changing code is a whole lot easier than changing all those databases!
I've found a way to make content_profile work with custom database fields or CCK fields or any combination thereof. It wasn't saving to my custom fields out of the box because it believed it was only updating the database record, and it ran "update" on a field that didn't exist! So in hook_insert I just added a very simple query to see if the database record in question was there. If it's there, run hook_update, otherwise revert to hook_insert.
So I think the problem is solved. Thanks for your input.
Certainly was a headscratcher trying to make mysql date fields work, but I got there eventually. Had to strip leading zeros! Who knew...
Cheers,
Tom
Creating node types with code.
I don't understand your problems with CCK or any of the issues relating to multisite so I will just add a few comments on creating a node type in code.
Node_example.module is the main demonstration programs used within Drupal api documentation for teaching people to create a module in code that provides a new node type. In doing this it demonstrates how to add a new table to the database. In this case the new table contains a color, a quantity, indexed by nid and vid.
The node_example module has an extension demonstration program at http://groups.drupal.org/node/17236. This demonstrates how to add Views 2 integration to allow views to create reports with the data from the new table.
After you install the module that creates a new node type, using the techniques shown in node_example, you will find that the new node type acts almost exactly like a node type created with CCK. You can even add additional fields to the node type using CCK.
If you go to admin/content/types you will see the new type listed and can click on the edit link for it. If you have also installed the Content profile module you will now find that you have a Content Profile section where you can enable the 'Use this content type as a content profile for users'.
After you enable this, and clicked the 'Save Content Type' button, you will find an extra 'Content Profile' TAB for this type. This allows you to specify most of the parameters as to how to use it as your profile. The only part that you will find missing is that you cannot specify fields to hide during registration as it only knows about the fields created by CCK.
If there are specific fields you want to hide during registration, you might look at adding just those fields by CCK. In doing so, you will find those fields in the database in a separate table called content_type_NODE_TYPE where NODE_TYPE is the node type. For example, if this was the node_example module then the table would be called content_type_node_example. The fields will be indexed by nid and vid similar to the node_example demonstration.
I get the impression that you have found out the hard way a lot of the above. I only just noticed this thread but I thought I would put it together for others that may not understand the above.
Ken
AusValue.com