Location info (and other 'addon' info)

sethcohn - September 25, 2005 - 21:00
Project:Import-export
Version:HEAD
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Module works great as written, but when you have modules like location turned on, that info is not exported (And I'll assume not imported either)

Any chance of making it do a full export and full import of all node info?

#1

tma0 - October 12, 2005 - 22:37

Unfortunately when a module implements new fields, the fields are not automatically supported. It requires to add a few lines of code - implement import-export API call. It's easy but I implemented only modules which I need myself.

#2

sethcohn - October 13, 2005 - 13:35

Example code, to make this easier to add to other modules?

#3

tma0 - October 14, 2005 - 16:14

Here is example from weblink module (older 4.5):

<?php
function weblink_nodeapi(&$node, $op, $arg = 0, $arg2 = 0) {
 
$default_fields = array(
   
'weblink'=> array('type'=>IMPORT_EXPORT_ATTR, 'name'=>'url', 'element'=>'_weblink'),
   
'author'=>array('type'=>IMPORT_EXPORT_ELEMENT, 'element'=>'_weblink'),
   
'publisher'=>array('type'=>IMPORT_EXPORT_ELEMENT, 'element'=>'_weblink'),
   
'translator'=>array('type'=>IMPORT_EXPORT_ELEMENT, 'element'=>'_weblink'),
   
'dateofissue'=>array('type'=>IMPORT_EXPORT_ELEMENT, 'element'=>'_weblink'),
   
'rating'=>array('type'=>IMPORT_EXPORT_ATTR, 'element'=>'_weblink'),
   
'monitor'=>array('type'=>IMPORT_EXPORT_ATTR, 'name'=>'enable', 'element'=>'_monitor'),
   
'refresh'=>array('type'=>IMPORT_EXPORT_ATTR, 'element'=>'_monitor'),
   
'threshold'=>array('type'=>IMPORT_EXPORT_ATTR, 'element'=>'_monitor'),
//    'feed'=>array('type'=>IMPORT_EXPORT_ELEMENT),
   
'spider_site'=>array('type'=>IMPORT_EXPORT_ATTR, 'name'=>'site', 'element'=>'_monitor'),
   
'spider_url'=>array('type'=>IMPORT_EXPORT_ATTR, 'name'=>'url', 'element'=>'_monitor'),
   
'_weblink'=>array('type'=>IMPORT_EXPORT_FAKE, 'name'=>'weblink', 'level'=>IMPORT_EXPORT_PUBLIC),
   
'_monitor'=>array('type'=>IMPORT_EXPORT_FAKE, 'name'=>'monitor', 'level'=>IMPORT_EXPORT_PUBLIC2)
   );
  
  switch (
$op) {
    case
'import_export':    // import_export module API hook
     
switch ($arg) {
        case
'fields':
          if (
$node->type == 'weblink') {
           
import_export_add_fields($node, $arg2, $default_fields);
            if (
$vid = variable_get("weblink_lang_vocabulary", "")) {
             
$node->import_export_fields[(string) $vid]['format'] = IMPORT_EXPORT_TERM_FORMAT_NAME;
            }
          }
          return;
        case
'types':
          return array(
'weblink'=>'weblink');
      }
      return;
  }
}

?>

and another example from my keywork_links (http://drupal.org/node/13717) module:

<?php
function keyword_links_nodeapi(&$node, $op, $arg = 0, $arg2 = 0) {
 
$default_fields = array(
   
'keywords'=> array('type'=>IMPORT_EXPORT_ELEMENT, 'level'=>IMPORT_EXPORT_PUBLIC, 'flags'=>XML_FLAGS_BR)
  );
  switch (
$op) {
.....
    case
'import_export'// import_export module API hook
     
switch ($arg) {
        case
'fields':
         
import_export_add_fields($node, $arg2, $default_fields);
          break;
      }
      break;
  }
  return
$output;
}
?>

PS: why is not nicely indented :-(

 
 

Drupal is a registered trademark of Dries Buytaert.