I'm starting this issue to have a public space for discussing further development of the extension module.
1. Module name.
I'd suggest we prefix all modules in this project with content_profile - so we have a common namespace. What about calling the module "content_profile_user_registration" or "content_profile_register" to be shorter? I think doing this change, should be a question of search & replace.. ;)
I think we should also create directories, so we don't mix up files from different modules.
2. Enable per content type
When one has multiple content profile, probably one only wants registration integration for a few of them.
3. Settings integration?
Content profile supports adding settings of extension modules, see content_profile_settings_info() and content_profile_content_profile_settings(). Then one only needs to add the settings in the form by using hook_form_alter(). Perhaps we should make use of it for a per content type kill switch, or even for all settings added in a own fieldset? Probably it makes sense to have all content profile related settings per content type together on a page. What do you think?
4. I think the module can depend on CCK, as without it does nothing, or?
Comments
Comment #1
jgraham commented1. The name doesn't matter much to me, and I can see the namespace issues as a plus. However, it should be clear that any "core" functionality should be either builtin in the parent module or as an include library separate from all other helper modules making the namespace issues largely isolate outside of any extension module. One argument against is the hook you suggest in 3. would be 'content_profile_register_content_profile_settings' for the "short" version. Following CCK's style the widgets are in their own respective namespaces too.
2. Right now it exposes all required fields, and optionally any selected fields from the various content types as set in the config. To clarify you are suggesting a way to select which content types are even allowed to show up on the registration page regardless of the presence required fields? As long as the UI isn't too bad, and the defaults are sane (eg. what most people would want/expect) that's fine.
3. I'm not sure I quite follow exactly what you are saying, but assuming I do; as long as the number of different content types remains small (less than 3) a config screen for each content type doesn't sound too bad. However if there are very many content types then this could become unwieldy fast.
4. Yes, I was unsure of whether or not it made sense to expose the default "body" for each content type and as a result hesitated on putting content as a requirement. Assuming that we don't expose the body then yeah adding content as a requirement makes sense.
Comment #2
fago1. hm, I know content_profile_register_content_profile_settings is a bit long, but it's only one function name, which gets a bit long as content_profile is already quite long.
@CCK: I know CCK does it that way and I don't like it. It introduces no problems as anyone knows and respects CCK, but potentially a "field" project would conflict with field module and so on.. As well as for the hook names. I think we should avoid every possible problem with this when possible and properly prefix our modules and hooks.
So if this is ok for you, I'd go ahead and prefix the module and create directories for the modules.
2. We can enable it per default, so users don't have to look for the setting after enabling the module.
3. Have you seen the settings provided by content profile? They are per content-profile type in a own tab like the settings of CCK. I propose to include "registration integration" settings there in a own fieldset - so one can control all content profile related settings of a content type from one screen.
For including settings there hook_content_profile_settings() and hook_form_alter() can be used.
If one really has a lot of content profiles, more than three or so I don't think it's so bad if you have one screen per content type. So even then the screens keep neat. Yes you have to go to through the page for each content type, but you'll have to go through the per content-type settings anyhow when setting up fields per content type.
4. I leave this up to you.
Comment #3
jgraham commented1. Agreed, done
2. Will figure out what makes sense when I implement 3.
3. Yes, I'll rework the settings to fit into there.
4. I'll leave this for last and see if anyone else chimes in.
Comment #4
jgraham commentedI think I have adjusted everything as discussed here.
Take a look and let me know if I missed anything.
re #4 I added content as a requirement; if we decide to expose body fields at a later date we will need to adjust this.
Comment #5
fagogreat! However I think it still needs quite some love, so I'll reopen it for now.
* First off be sure to follow the coding style! I've just improved the coding style of the main module. You can use the "coder" module, which is a great help here.
* Then please be sure to add some useful comments, in particular comment each hook implementation as it's usually done in drupal.
* The call "module_load_include('inc', 'content', 'includes/content.node_form');" sits directly in form_alter, which lets it include the file far too often.
* The validation routine can't work like it is now. As we have the form_state now, probably we should save the name of all fields we added in the form state, so we can avoid this ugly preg_match() call during validation.
* Nodeapi op submit is gone in d6, so this can be removed.
Then ease settings code by using the content profile API. If you want I can do the changes.
-> implement hook_content_profile_settings
-> remove the own the form submit handler, as it's unnecessary then.
-> use content_profile_get_settings() to retrieve the settings. Note that also content_profile_get_types() has useful "setting support".
Comment #6
jgraham commentedAnything else should probably go into a new ticket.
Comment #7
fagogreat - the code looks good now!
I just gave it a short test and noted that it doesn't work with required radios. Then what's if people use the fieldgroup module? As of now i think this case isn't covered, perhaps we should invoke the fieldgroup module manually? But what happens if there are not all fields it awaits?
Probably we just keep it "cck fields only" and simple.
To get the whole form looking as in the node, it's probably a good idea to use the subform_element module, as I did for nodeprofile.
@ module_invoke_all('submit', $node);
I think there is no such hook in d6?
@Perhaps its best if you cover this?
ok, I'll do.
Comment #8
fagoso, I just overworked it to make use of the settings API.
I have also fixed up the comment style to better follow drupal code style. Furthermore I
* fixed the display select to show only NOT required fields, so people can't unmark required fields
* added a note to the settings page when the module is disabled because there are no cck fields.
* changed the registration form to build the node properly during validation and to save the same node on submit
* changed the registration form to store the info about added fields in the form state so we need no preg_match() call
It should work as before - validation works too.
However furthermore I noted that,
* the node author isn't set right
* there are a lot of notices we need to fix
@node author:
$node->name isn't used when the user doesn't has node administration permissions. So this needs to be done manually, I remember that I had something like that implemented in nodeprofile's registration code.
@groups:
* An idea came up to my mind, perhaps it would make sense to optionally use the subform element when it's available? Or as an option.. Don't know.
Comment #9
jgraham commentedThanks for reworking it to use the settings API of content_profile.
Probably we just keep it "cck fields only" and simple.
* An idea came up to my mind, perhaps it would make sense to optionally use the subform element when it's available? Or as an option.. Don't know.
Comment #10
jgraham commentedI reworked the logic of _content_profile_registration_get_field_select() to reflect the changed prototype and comments. The settings form also needed some tweaking to reflect the changed _content_profile_registration_get_field_select()
Comment #11
fagooh, sry I was a bit too quick there. I simplified the logic to
- which should be equivalent. :)
@preg_match: I've already cleaned that up with my last commit.
@groups: I agree that we should stay simple and avoid complicated options :)
Comment #12
fago@author: I've just fixed setting the right author.
Comment #13
fagoRecently I've done some work on embedding node forms in d6. This explains who to avoid some pitfalls: http://more.zites.net/embed-a-node-form-with-drupal-6
With this knowledge and some further investigation for CCK I overworked the code a bit. I changed it also use drupal_retrieve_form, as CCK needs to have it's #fieldinfo available. I was able to get #radios working that way, as well as the #ahah callbacks - so you can use a CCK field with "add more" button without errors or notices :)
I also changed the setting, so that one has to specify the fields to hide now, because it was more straight forward to implement.
This seems to work fine now, however I think it will break when one moves the fields in a fieldgroup. We need to have a look at this.
Comment #14
jgraham commentedThis ticket is getting unwieldy, I'm closing it.
Any remaining issues can be opened as new issues.
The only thing I see remaining is implementing fieldgroups. This shouldn't hold up our next beta release and I will open a new ticket for that. If there is anything else I missed that needs attention please open a new ticket.
Comment #15
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.