0

My question is similar to this guy's from drupal.org: https://www.drupal.org/node/2283931

But, I have reference nodes that import content from various URLs and I want after each import, to change the (feeds source) URL of the reference node. I guess I will use hook_feeds_after_import() but how am I going to target the reference node instead of the importer and run a function on that source?

1 Answer 1

1

Answering my own question, it's basically the same. The $source object is the node itself, so in my module I called a hook like this:

function MYMODULE_feeds_after_import(FeedsSource $source) {

    //Get the config
    $config = $source->getConfig();

    //Save the current URL
    $url = $config['FeedsHTTPFetcher']['source'];

    //Run a basic check
    if(strstr($url, 'since')){

        //Do some fancy stuff with it and create a new one

        $newurl = 'http://foo';

        //Save the new configuration in the source node
        $config['FeedsHTTPFetcher']['source'] = $newurl;
        $source->setConfig($config);
        $source->save();
    }

}
1
  • 1
    In my case, I want to change the URL before the import happens so I'm using hook_feeds_before_import() instead. Need to add different parameters each time.
    – colan
    Commented Dec 16, 2015 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.