Support for "drigg" module
totaldrupal - March 1, 2008 - 19:22
| Project: | Node import |
| Version: | 5.x-1.5 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
It would be great if node import supported the "drigg" module ( http://drupal.org/project/drigg ). The title and description fields are already present on import but no URL field :(
Drigg admin offered their help http://drupal.org/node/228213

#1
Hi,
I am the maintainer of Drigg.
I have never used Node_import. However, it would be great if this issue could be resolved... Is there anything I can do to help?
Bye,
Merc.
#2
The thing I need to know is:
- what fields do drigg nodes have (eg the title, the body (which is probably description), ...) ?
- how are those fields stored in the $node object ?
If it is just an extra URL field (next to title and body/description), then I only need to know where in the $node object (not in a table) this is saved.
edit: This assumed that you are using hook_nodeapi() or hook_save() to save that extra data. If you do this with some hook_form_alter(), I'd need to know how you store it in your database tables.
#3
Maybe some code (untested):
<?php
/**
* Implementation of hook_node_import_types().
*/
function drigg_node_import_types() {
// replace 'drigg' by the node type
// replace 'Drigg node' by the human readable form
return array('drigg' => t('Drigg node');
}
/**
* Implementation of hook_node_import_fields().
*/
function drigg_node_import_fields($type) {
$fields = array();
if ($type == 'drigg') {
// replace 'drigg_url' by what field in $node this is stored
// replace 'Drigg URL' by what the human readable form
$fields['drigg_url'] = t('Drigg URL');
}
return $fields;
}
/**
* Implementation of hook_node_import_prepare().
*/
function drigg_node_import_prepare($type, &$node, $preview) {
$errors = array();
if ($type == 'drigg') {
// Here you can add validation, eg:
if (empty($node->drigg_url)) {
$errors[] = t('The drigg URL is required.');
}
else if (!drigg_is_valid_url($node->drigg_url)) {
$errors[] = t('%drigg_url is not a valid URL.', array('%drigg_url' => $node->drigg_url));
}
}
return $errors;
}
?>
Or something like that.
#4
Hi,
Thank you for your answer!
The module does use hook_save :-D
Now... is it just a matter of testing the code you place up there?
ALSO, it's absolutely crucial that we also do:
drigg_url_exists()
If drigg_url_exists() returns true, then the import should puke for *that* particular record (is that how it works?)
I have no way to test the code above. However, I will just commit it, and get my users to test it!
Please let me know :-D
Merc.
#5
I'd prefer it being added to node_import itself (which means adding a drigg.inc file in modules/node_import/supported) because this way I can keep better track of what features node_import currently supports. No other module currently implements the hook_node_import_* hooks inside their own code right now, they all have the code in this supported directory.
The code above is not completely correct, it was intended as just a quick start for you. But if there is nothing more then the URL and you don't do fancy non hook_save() stuff, then it will be pretty easy to do it myself.
This drigg_url_exists() : does this mean that only one URL is allowed site-wide? In hook_node_import_prepare() this would then indeed be tested for that particular record.
I'll look into it later this week and add the feature to node_import.
#6
#7
Hi,
No worries about adding it as drigg.inc to your module!
The extra fields are:
* promoted_on int(11) (it's a timestamp)
* killed (just a 1/0 flag)
* url char(255) (the one to be checked, ONE site-wide)
* title_url (just a string)
* safe_section char(128) (again, just a string)
* content_type char(32) (just a string)
* trackback_ping_url (just a string)
trackback_ping_successful (one or 0)
The module saves everything through node_save(). So, it should just be a matter of mapping these fields "straight".
Is it still OK for you to add them?
Thanks a million!
Merc,