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).

Files: 
CommentFileSizeAuthor
#15 easyconfigimport_1946222.patch4.04 KBiyyappan govind
PASSED: [[SimpleTest]]: [MySQL] 1,536 pass(es).
[ View ]

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.

komlenic’s picture

ajf__ I can confirm that the code in #3 works. Be aware that you do need to add "return $export;" at the end of the MYMODULE_feeds_tamper_default() function, after you paste the code provided by the export tab of the feeds tamper ui interface.

liquidcms’s picture

sorry guys.. #3 is not the way to do this and it is not the solution for what i was asking.

like most things which have an exporter; they also have an importer (importer form as twistor mentions in #6) - writing a custom module to import setup.. really??

and, as i suggested above, the best way for this seems to be that the feeds config exporter include the tamper export and then the feeds importer (already an importer form for this) use that "complete" export to build both the feed and tamper config.

never looked at importer/exporter code but perhaps i should take a look.. :)

iyyappan govind’s picture

Hi

We already have feeds tamper plug-in export in the tamper page of the feeds importer. So i have implemented module called feeds tamper plug-in importer.

Please check this link:

https://www.drupal.org/node/2597207

Thanks

iyyappan govind’s picture

Assigned:Unassigned» iyyappan govind
Status:Active» Fixed
parisek’s picture

Title:Add Tamper plugin importer.» Add form to Feeds Tamper UI to allow easy configuration importing
Status:Fixed» Needs work
Related issues:+#2597207: Feeds Tamper Importer

iyyappan govind Please create patch from your project application https://www.drupal.org/node/2597207 I'm looking forward for your contribution!

iyyappan govind’s picture

Status:Needs work» Needs review
StatusFileSize
new6.42 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch easyconfigimport_1946222.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Parisek thanks for your suggestion. I have created the patch for feeds tamper plug-in importer.

Status:Needs review» Needs work

The last submitted patch, 13: easyconfigimport_1946222.patch, failed testing.

iyyappan govind’s picture

Status:Needs work» Needs review
StatusFileSize
new4.04 KB
PASSED: [[SimpleTest]]: [MySQL] 1,536 pass(es).
[ View ]

I have created the updated patch for feeds tamper plug-in importer.

Abelito’s picture

The patch in #15 works great! I haven't found any problems with it.
Thanks @iyyappan-govind

liquidcms’s picture

Title:Add form to Feeds Tamper UI to allow easy configuration importing» Include tamper export/import in Feeds export/import.
Status:Needs review» Needs work

Not sure why the push back to not have this included as part of Feeds importer/exporter. Do people use a Feeds Tamper without Feeds? Only reason I can think of why this would need to be a separate tool.

parisek’s picture

Title:Include tamper export/import in Feeds export/import.» Add form to Feeds Tamper UI to allow easy configuration importing
Status:Needs work» Reviewed & tested by the community

liquidcms You're right, nobody uses Feeds Tamper without Feeds, but this issue is for Feeds Tamper module. Your proposal must be resolved in Feeds module, feel free to open new issue. In the meantime we have a working patch so please do not change topic and hopefully it will be merged soon.

liquidcms’s picture

btw.. i am original poster... so pretty sure i'm allowed to change topic.. :)

and yes, nice to have something added to Feeds Tamper.. but if its the wrong way to do it; why bother?

parisek’s picture

I'm sorry, didn't notice that. But how could Feeds Tamper alter Feeds export? I think it's not possible.

Generally it's better to have some solution then no solution:-) But final word is up to module maintainer.

de-shunda white’s picture

The patch from #15 worked great for me. There are only 2 points I'd like to make. The first point are for individuals who are manually applying this patch. In the patch provided it isn't 100% clear which other file needs to be edited for the second part of the patch. The first part is [@@ -59,6 +59,17] refers to feeds_tamper_ui.module. The second part [@@ -215,3 +226,96] refers to feeds_tamper_ui.admin.inc in the feeds_tamper folder.

Secondly if the order of the plugins are critical for a certain functionality you will need to rearrange the plugins since the export tamper functionality presents the plugins in reversed order. For me I had to rearrange the Rewrite and Explode plugins for my content to present properly.

hargobind’s picture

This patch works great!

The only thing that's missing is the "override" checkbox that you see in other import pages (e.g. Views import) that says something like "Replace an existing [item] if one exists with the same name".

iyyappan govind’s picture

Hi,

@hargobind thanks for your review ...i will do the "override checkbox".

Thanks,

portulaca’s picture

Thank you for the patch #15, it works (don't forget to clear cache).