not sure if this is a support request, feature request or bug report.

how do i import a tamper config export? (please don't say using Features.. ughh).

Comments

Nodz’s picture

I'm interested in this too.

Feeds offers a hook for importing feed set ups via modules (like the example feeds import).

/**
* Implementation of hook_feeds_importer_default().
*/

Having a similar hook for importing feeds tamper plugin setups via file would allow creating self contained modules for an import with both feeds and feeds_tamper settings.

I'll look and see if there is such a hook or if one could be easily implemented.

meecect’s picture

Any update on this? It would be very useful. Here is a code snippet of a similar function in the feeds module:

assuming your feeds importer config (that you exported) is $feeds_importer:

  $importer = feeds_importer($feeds_importer->id);
  $importer->setConfig($feeds_importer->config);
  foreach (array('fetcher', 'parser', 'processor') as $type) {
    $importer->$type->setConfig($feeds_importer->config[$type]['config']);
  }
  $importer->save();

A similar API for feeds tamper would be nice.

jgutix’s picture

You need to implement hook_feeds_tamper_default, like this:

<?php
function MODULENAME_feeds_tamper_default() {
}
?>

Then in order to your function be executed you should declare like this:

<?php
function MODULENAME_ctools_plugin_api($module = '', $api = '') {
    if (
$module == "feeds_tamper" && $api == "feeds_tamper_default") {
        return array(
"version" => "2");
    }
}
?>

Here you have a complete example

<?php
function dummy_module_ctools_plugin_api($module = '', $api = '') {
    if (
$module == "feeds_tamper" && $api == "feeds_tamper_default") {
        return array(
"version" => "2");
    }
}

function
dummy_module_feeds_tamper_default() {
   
/*This is the code resulting after export a feed tamper*/
   
$export = array();

   
$feeds_tamper = new stdClass();
   
$feeds_tamper->disabled = FALSE; /* Edit this to true to make a default feeds_tamper disabled initially */
   
$feeds_tamper->api_version = 2;
   
$feeds_tamper->id = 'module_publication_importer-prd_code-keyword_filter';
   
$feeds_tamper->importer = 'module_publication_importer';
   
$feeds_tamper->source = 'prd_code';
   
$feeds_tamper->plugin_id = 'keyword_filter';
   
$feeds_tamper->settings = array(
       
'words' => 'DUMMY',
       
'word_boundaries' => 0,
       
'exact' => 0,
       
'case_sensitive' => 0,
       
'invert' => 0,
       
'word_list' => array(
           
0 => 'DUMMY',
        ),
       
'regex' => FALSE,
       
'func' => 'mb_stripos',
    );
   
$feeds_tamper->weight = 0;
   
$feeds_tamper->description = 'Keyword filter';

   
$export[$feeds_tamper->id] = $feeds_tamper;
    return
$export;
}
?>
liquidcms’s picture

Category:Support request» Feature request
Issue summary:View changes

still no progress?

liquidcms’s picture

Priority:Normal» Major

Ideally i think the Feed export should contain the Feed Tamper export; would that not make the most sense here? This way, a feed export is completely self-contained - and it also would fix this issue where there is no feed tamper importer (which is pretty silly to have an exporter with no importer).

twistor’s picture

Title:how to import a tamper export?» Add Tamper plugin importer.
Priority:Major» Normal

#3 is correct, the export mechanism is meant for creating a custom module.

We could add an import form, I guess, but using Features or a custom module is really the way to go.

If somebody wants to implement this, I am willing to commit it.

ajf__’s picture

I've created a module for my Feeds Tamper default using the code above as a guide and replacing the dummy Feeds Tamper export code with my own.

I enabled my module and cleared all caches, but I don't see any difference in the Feeds Tamper UI. The blank defaults are still there.

Is there another step I'm missing?

All I hope to achieve is duplicate an existing Feeds Tamper config.