0

A student newspaper I work with is needing some way of importing XML files from InDesign. I'm thinking Feeds/Feeds XPath Parser is the best route for this.

However, one problem with this is that each week the Production Editor will need to import 4-8 XML files, one for each section. "Section" is a taxonomy field in the Drupal "Article" content type, and it's listed nowhere in the XML files they output.

To this end, is there any way to manually set the values of certain fields when importing, on a per-import basis?

I'm thinking this would look like a text box that shows up in Feeds UI when uploading the XML file. Feeds Tamper seems like an idea, but it looks like it's more designed to set default values, and less set specific values on a per-import basis.

Any thoughts?

1

There's also hook_feeds_after_parse() which lets you modify what's being saved to to your targets. Something like this should work:

function my_module_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {

  if($result->title == 'title-of-feed-importer') {
    foreach($result->items as $item_key => &$item) {
      if ($item_key == "name-of-the-field") {
        $item = 'Value to set';
      }
    }
  }

}
0

Seems I didn't really need to do anything really differently.

Feeds XPath Parser gives you fields to change XPaths while importing. If you use the syntax:

string('News')

...in place of an XPath, it will assign the value ('News', in this case) as the output (Which works fine for taxonomy terms).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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