Importing News with a jSON Feed

Yale News (news.yale.edu) is the main source of news related to the academics, research and community activities. You can include articles from the Yale News site in your news listing by importing one of the Yale News jSON feeds with the Feeds Module and making a few adjustments to the News Content Type. 

While you can use the basic RSS Feed to pull this information, you won’t have a lot of control over what is pulled into your site. For the most part, you can import the title of the article, the description and the date. If you want to exercise more control and import the picture, you can use a jSON feed.  

Adjust the News Content Type to set incoming articles to unpublished

By default, the news articles created with the News Content Type are published. However, once you setup the jSON feed to import articles into the News Content Type, you’ll most likely want to monitor how and when they are published.

  1. Select Structure > Content Types > News
  2. Scroll down to the Vertical Tabs and click on the Publishing Options tab and uncheck the Published checkbox.
  3. Set the External Link field to redirect to the url for the news article.
    • When an article is imported, it creates a page, but you most prefer the link point directly to the actual news article. You can do this using the Field Redirection Module. Just enable the Module and configure the field based on the image below:

Create a jSON importer with the Feeds Module to pull in the news articles

In order to pull in the entire feed, including the image, we need to use the json feed setting when creating the feeds importer. 

  1. Enable the Feeds UI Admin and JSONPath Parser module (the Feeds Module is enabled by default).
  2. Select Structure Feeds importer Add importer
  3. Give the importer a Name and Description and click Create.
  4. Click on Settings in Basic settings section and only change the Periodic import if desired. This determines how frequently the importer pulls articles from the jSON feed.
  5. Click on Change in Fetcher to select the method to pull the feed. To pull RSS feeds, use HTTP Fetcher and Save.
  6. Click on Change in Parser and select the jSONPath parser  and Save.
  7. Click on Settings next to JSONPath parser/Parse JSON using JSONPath and click on Select.
  8. Then jump down to the Processor section and change the Node processor settings and Mappings.
  9. Jump down to Processor and click on Change; select the Node processor (to pull content into a specific Content Type).
  10. Click on Settings in Processor and select the News Content Type to pull the content into and Filtered text into the Text format
  11. Change the Author to someone assigned administrator privileges on your site. DO NOT leave Anonymous.
  12. Then click on Mapping to set the target to match the source during the import:
    • Select JSONPath Expression from the Source dropdown then select the field you want to map to in the Target column. The source will display as jsonpath_parser:0 and then the field name next to it. ​
    • Create the fields in the following order:
      • jsonpath_parser:0 Title
      • jsonpath_parser:1 Body
      • jsonpath_parser:2 Publication Date: Start
      • jsonpath_parser:3 External link: URL
      • jsonpath_parser:4 GUID (Set as unique)
      • jsonpath_parser:5 Image
    • Your settings should look like this: 
  13. Go back up to Parser, and change the JSON Path Parser settings as follows (see image for exact details). Be sure to Save when you are done.
    • Context: $.news.*.node
    • title: title
    • body: description
    • field_data:start: date
    • field_link_to_external_story:url: path
    • guid: guid
    • field_news_image: image

Import the jSON Feed

Once you have created the importer, you can indicate the jSON feed to pull in and import the jSON feeds.

  1. Go to http://yoursitename.yale.edu/import
  2. Click on the Importer you have created (in this example, news.yale.edu).
  3. Enter one of the URLs for the news feeds:

Publishing Imported Articles

Once the news items are imported, you can choose the ones you want to publish, upload an  image and click on the Published checkbox to make it live.