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

Support from Acquia helps fund testing for Drupal Acquia logo

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:

function MODULENAME_feeds_tamper_default() {
}

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

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

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: [D7] 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
FileSize
6.42 KB

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
FileSize
4.04 KB

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.

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

checker’s picture

Confirm this patch works without any issues (also order is correct).

I guess it is not necessary to add an override option. This should be a new feature request.

NWOM’s picture

#15 worked amazingly. It saved me at least an hour of work. Thank you!

g33kg1rl’s picture

I tried the patch in #15 and I received this error message after clearing the cache and going to the import page

Notice: Undefined index: feeds_tamper_ui_import_form in drupal_retrieve_form() (line 806 of /var/aegir/platforms/$platformname/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'feeds_tamper_ui_import_form' not found or invalid function name in drupal_retrieve_form() (line 841 of /var/aegir/platforms/$platformname/includes/form.inc).

joseAyudarte91’s picture

Hi,

May be it is a silly question but, ¿Does have anyone checked the patch with the 7.x.1.1 (current release) version?.

Many thanks and best regards,

Jose

bisonbleu’s picture

Patch in #15 works as advertised. Good work @iyyappan.govind!

One thing, tamper settings associated to an importer are not deleted when the importer is deleted. You have to uninstall tamper to do that - WARNING in doing so, ALL tamper settings are deleted.

It would be nice, and make for a more coherent UX, if the child tamper settings were automatically deleted when the parent importer is deleted.

Cheers

iyyappan.govind’s picture

@bisonbleu Thanks for reviewing this patch . Sure i will do the changes.

iyyappan.govind’s picture

@bisonbleu ,

Feeds tamper settings is deleted. Please check the patch with feeds module version 7.x-2.0-beta2 and feeds_tamper module version 7.x-1.1.

Please let me know if you have any issues

Thanks,

droweski’s picture

Patch in #15 works !!. Good work @iyyappan.govind!
Tested with:
Feeds: 7.x-2.0-beta2
Feeds Tamper: 7.x-1.1

geru’s picture

Title: Add form to Feeds Tamper UI to allow easy configuration importing » Needs weight
Category: Feature request » Bug report
Status: Reviewed & tested by the community » Needs work

Nice work iyyappan.govind. I like this patch.

I'm not sure how to patch a patch, but this patch really needs to assign the weight properly. Without this, multiple tampers will not be ordered correctly.

I have submitted a patch on your sandbox site https://www.drupal.org/sandbox/iyyappangovind/2597049

Basically, a single line needs to be added:

          $obj->weight = $value->weight;

just before the feeds_tamper_save_instance()

Thank you.

MegaChriz’s picture

Title: Needs weight » Add form to Feeds Tamper UI to allow easy configuration importing
Category: Bug report » Feature request

Restoring issue title and category.

puddyglum’s picture

patch in #15 worked perfectly. rtbc?

NWOM’s picture

Assigned: iyyappan.govind » Unassigned
Status: Needs work » Needs review
FileSize
4.01 KB

When applying #15 the following warning is shown:

easyconfigimport_1946222_0.patch:9: trailing whitespace.

I have fixed the whitespace error and added the change mentioned in #33. Please review.

garrettw’s picture

#3 really needs to be added to the documentation for this module. Could someone do that?