Build a Drupal-Free With 8's REST API and Javascript: DrupalCon Austin Session Notes

June 4, 2014 by Wayne Eaker
: Theme Developers
Build a Drupal-Free With 8's REST API and Javascript: DrupalCon Austin Session Notes

Session Link: https://austin2014.drupal.org/session/build-drupal-free-theme-8s-rest-api-and-javascript

Drupal Theming

  • Divitis
  • A lot of Drupalisms all throughout the HTML
  • Lots of templates to override to do simple things

A Different Approach

  • AngularJS
  • Need raw data for Angular. No theming, no divs, etc.
  • Web Services and REST in Drupal 8 core
  • Accept header: application/hal+json
  • CORS module: allow pulling data from a different URL from the site you're on.
  • Client Side Theme: Not a Drupal theme. Totally decoupled.

Angular

  • index.html, app.js, angular.js
  • ng-controller: Builds a $scope variable like $variables array in normal theme.
  • Use $http service to do REST request
  • Create an Angular "service" for retrieving data of a particular type
  • Routing: angular-route.js
  • Wildcards with $routeparams
  • Can specify template files for your various routes.
  • DBLogResource module: example of wrapping custom data in REST in D8

Do you want to become an expert Drupal developer? Our classes will get you there in record time!

"The entire course was much more than I expected. I did attend a previous Drupal course, but there was no comparison. This ecourse rocks!"
Missi - Webmaster at a public library system