feeds

Feeds JSONPath Parser

1) Identify the json URL, and look at it using this tool: http://jsonviewer.stack.hu/ (or, if you know the json well, identify what you want to import.

2) Download jsonpath php file here: http://jsonpath.googlecode.com/files/jsonpath-0.8.1.php and place inside sites/all/modules/feeds_jsonpath_parser

3) Create a new parser using feeds, with the jsonpath parser selected

4) Example json:

{
  "tumblelog": {
    "title": "Tumblr Blog",
    ..... (other global fields)
  },
  "posts": [
    {
      "id": "46252144726",
      "url": "http://whatever.com",
      "type": "regular",
      "date": "Mon, 25 Mar 2013 10:45:38",
      "regular-title": "Test Blog Entry",
      "regular-body": "Body text goes here",
      "tags": [
        "tag1",
        "tag2",
      ]
    },
   {
      "id": 46249331035,
.... rest of posts

OK, so now is where I'm getting unclear, and need help.

5) In the jsonpath parser settings page:admin/structure/feeds/rss_feed_importer/settings/FeedsJSONPathParser there are two elements, "Context" and "Title". In the Context field, if you want to map the variables in post, to fields in a blog content type, for example, you need to let jsonpath parser know where to start. So in this case, the context would be:

$.tumblelog.posts.*

Read more

Processing large amounts of data

Feeds processes data using the Batch API. You can avoid hitting a page time-out when processing large amounts of data by keeping count of the processed elements and setting the batch progress.

The simplest example of implementation can be found at feeds/includes/FeedsBatch.inc:

<?php

class YourFeedsProcessor extends FeedsProcessor {
// Total elements to process per page
const MAX_PER_PAGE = 50;

/**
* Update your process() method within your custom Feeds processor with the following logic.
*/
public function process(FeedsImportBatch $batch, FeedsSource $source) {
// Set counter of processed elements for this page load.
$processed = 0;
// Set counter of all processed items across page loads.
if (!isset($batch->processed)) {
$batch->processed = 0;
}
// Set total elements
if (!$batch->getTotal(FEEDS_PROCESSING)) {
$batch->setTotal(FEEDS_PROCESSING, count($batch->items));
}
// Loop items
while ($item = $batch->shiftItem()) {
// You can replace the following two lines by your custom logic to process nodes.
$object = $this->map($item);
$object->save();
$processed++; // Processed in this page load.

Read more

Feed Import Taxonomy Terms

Feed Import is a module that allows you to import content into entities from various file types (like XML, HTML, CSV).
In this page we will find how to import taxonomy terms.

Read more

Mailhandler Single Mailbox

Introduction

If you use the Mailhandler module and you want different user accounts to have their own mailbox to send content to a site, you are required to configuring multiple Mailhandler mailboxes for each account as well as multiple feeds to process each mailbox. The provisioning of mailboxes on a mail server and configuration of so many Mailhandler mailboxes and the associated feeds could be automated, but it would be pretty gnarly.

The solution we came up with was to have a single mailbox on the mail server, and have a single mailhandler and single feed processor for the a site. Instead of each user getting their own inbox, we have a single inbox that collects email from any number of addresses. This can be done by either configuring the mail server to have a single ‘catch all’ address or, if available, a plus addressing scheme (think GMail).

What does this module do?

The module exposes the 'Send content by mail' permission.
The module provides a user interface to generate unique 'email addresses' for each user on the site with the 'Send content by mail' permission.

Why is that useful?

Read more

Mass import of addresses with OpenLayers, Geocoder and Feeds

Introduction

By using Geofield, Geocoder, Address Field, Feeds, and Openlayers, you can create maps almost entirely from the GUI for most use cases, but at the moment Feeds can't import to Address Fields because it's dynamic. This might change in future.
Address field is useful because it gives you the proper number of fields for an address. The number and order of fields are dynamically updated when you select a country, because different countries have different address formats. Geocoder takes that address field and turns it into latitude and longitude points (“lat-longs”). Geocoder takes the lat-longs that it created and stores them in a Geofield.
Address field is great when you manually add locations, but when you want to mass import locations, you should use a regular text field and the Feeds module.

Instructions

Summary

For mass importing addresses you need to create

  1. a Feeds importer,
  2. a content type with an address field and a Geofield, which will geocode the address field,
  3. two views: one in which to have your page display and one in which to have your open data overlay,
  4. and a mapping (preset) within Openlayers.

Required modules

    Read more

    Mapping multiple values in one field

    While setting up a feed, you may need to map, merge or process more than one field into a single field, no matter if the input is coming from columns from a CSV, tags from an XML or any other source.

    Example

    Suppose that our source is a very simple CSV where there is the following structure:

    Name Surname
    Iggy Pop
    Tom Waits

    We want to merge both Name and Surname into a single field for our users table. Therefore, we will join this together into a new column "fullname" at hook_feeds_after_parse() and then define a mapper for this.

    Here is the hook implementation:

    /**
    * Implements hook_feeds_after_parse()
    *
    * Adds a key "fullname" to each result
    * @param $source
    *  FeedsSource object that describes the source that has been imported.
    * @param $result
    *   FeedsParserResult object that has been parsed from the source.
    */
    function mymodule_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
      foreach($result->items as $key => $row) {
        $result->items[$key]['fullname'] = $row['name'] . ' ' . $row['surname'];
      }
    }
    Read more
    Subscribe with RSS Syndicate content