Closed (fixed)
Project:
Node import
Version:
6.x-1.0-rc2
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Jan 2009 at 22:23 UTC
Updated:
17 Feb 2009 at 13:50 UTC
Sorry for not making a patch file but here is the code to for supported/profile.php
function profile_node_import_fields($type) {
if ($type !== 'user') return;
$fields = array();
$results = db_query('SELECT * FROM {profile_fields} ORDER BY category, weight, title');
while ($field = db_fetch_object($results)) {
$name = $field->name;
$fields[$name] = array(
'title' => check_plain($field->title),
'group' => check_plain($field->category),
'map_required' => $field->required,);
switch ($field->type) {
case 'selection':
$options = $field->required ? array() : array('--');
$lines = split("[,\n\r]", $field->options);
foreach ($lines as $line) {
if ($line = trim($line)) {
$options[$line] = $line;
}
}
$fields[$name]['allowed_values'] = $options;
break;
case 'date':
$fields[$name]['input_format'] = 'date';
break;
case 'checkbox':
$fields[$name]['is_checkboxes'] = true;
break;
default:
break;
}
}
return $fields;
}
Comments
Comment #1
Robrecht Jacques commentedNice!
Will commit to CVS after a bit of testing tomorrow.
Not sure about the 'is_checkboxes'. I think it is just
because the checkbox is only one value: either on or off. The 'is_checkboxes' is meant for stuff where you want
"published||promoted"to be converted intoarray('published' => 1, 'promoted' => 1)instead of an array of values (array(0 => 'published', 1 => 'promoted')).Are those all field types? Or do the others not need additional stuff?
Does it make sense to implement
hook_node_import_defaults()?Never really used profile myself.
Comment #2
uniqueculture commentedThose are all field types currently supported by profile module. Profile module is hooked to the user module and puts imported data into the right place. Selection type fields can potentially create some issues... never tested those.
Profile field can also have different visibility settings. Defaults feature can apply to the fields that are:
* Only accessible by administrators, modules and themes.
* Content only available to privileged users.
or while mapping fields under each profile field there will be a "Provide a default value for the field" checkbox and the field is going to show up on defaults step.
Lastly, I'm planning to write some code for cck fields support. Should I start from group-up or I can somehow contribute to current developments?
Comment #3
Robrecht Jacques commentedGreat you are going to follow up the profile support.
Do not provide a "Provide a default value for the field". I would prefer you just add all profile fields to the "Set default values" page. If the user fills in something, it will be used, otherwise it will be ignored.
I'm finishing the core CCK modules (Text, Number, Options, ...) right now and will commit before the end of the day. If you can build upon that (corrections, additional contrib CCK fields), that'd be great.
Comment #4
uniqueculture commentedI finally wrote "defaults" hook implementation:
Comment #5
Robrecht Jacques commentedCommitted to CVS. Thanks.