How to get your external data into Drupal John Hume Drupal.org: @littledynamo Twitter: @littledynamo1 DrupalCamp Scotland 2014
What is the Feeds module? “Import or aggregate data as nodes, users, taxonomy terms or simple database records.” drupal.org/project/feeds Basically … Feeds allows you to import external data into Drupal
A bit of history … Released in 2009 by DevelopmentSeed Part of Managing News distribution Written by Frank Febbraro @febbraro Maintained by Chris Leppanen @twistor Successor of Feed API and Feed Mapper Currently in Alpha – but don’t let that put you off!
Feeds S
Case Study – Career Timeline
Case Study – Career Timeline Timeline event content type • Over 600 nodes to be created • Data held in multiple spreadsheets • Feeds to the Rescue
The Fetcher
The Parser
The Processor
Feeds Anatomy Feeds Importer Basic Settings Fetcher Parser Processor Mapping
Fetchers Out of the Box File Upload HTTP PubSubHubbub Contributed HTTP Advanced Callback Directory Oauth Authentication Clients SOAP OAI-PMH Mailhandler Web Services HTTP Append LDAP SQL Client Headers FileMaker
Parsers Out of the Box RSS / Atom CSV OPML XML Sitemap Simplepie Contributed XPath iCal Flickr YouTube Vimeo LDAP FileMaker Slideshare Clients Regex Wordpress SharePoint LOTS MORE!
Processors Out of the Box Node User Taxonomy term Feed Node Contributed Data Comment Commerce product RedHen Node (Unique) Self node User contacts Node Multisource
CSV Import Demo 1. Create content type 2. Create CSV file 3. Add basic settings 4. Setup Fetcher, Parser and Processor 5. Add mapping 6. Import
Feeds Tamper drupal.org/project/feeds_tamper Provides a UI for modifying data before it gets saved Examples: • Replace every instance of 'dog' with 'cat'. • Combine separate 'firstname' and 'lastname' fields into one 'name' field. • Break a comma separated list of words into Taxonomy terms or a multivalued text field.
Customising Feeds – Program Flow Source : http://ygerasimov.com/feeds-cheatsheet-for-developers
Customising Feeds - Hooks Source: http://drupalcontrib.org/api/drupal/contributions!feeds!feeds.api.php/7
Before Import Source : http://ygerasimov.com/feeds-cheatsheet-for-developers
After Parse Source : http://ygerasimov.com/feeds-cheatsheet-for-developers
Presave Source : http://ygerasimov.com/feeds-cheatsheet-for-developers
After Import Source : http://ygerasimov.com/feeds-cheatsheet-for-developers
Feeds Hook Demo hook_feeds_after_parse()
Custom Plugins! Create your own Fetcher / Parser / Processor • Declare and Implement a Ctools plugin • Extend FeedsFetcher , FeedsParser , FeedsProcessor • If similar plugin exists, extend that class instead
Case Study – Staff Import from Staff Database stored in FileMaker Old D6 Custom Module Increasing requirement for FileMaker => Drupal Custom Fetcher and Parser
Case Study – Staff Import from feeds_filemaker_feeds_plugins() configForm(), sourceForm() - Settings getRaw() – retrieve the data from FileMaker parse() - normalise the data FeedsNodeProcessor does it’s thing
Resources List of Feeds contributed Fetchers, Parsers, • Processors and Mappers - https://drupal.org/node/856644 Feeds cheat sheet for developers - • http://ygerasimov.com/feeds-cheatsheet-for- developers Developers guide to feeds - • https://drupal.org/node/622700
Image Credits • Speedy Boy Delivery - https://www.flickr.com/photos/42424413@N06/5 954193181/ • Lego Chef - https://www.flickr.com/photos/dunechaser/16150 9118 • Storm Troopers - https://www.flickr.com/photos/st3f4n/444814037 7
Recommend
More recommend