It's no denying that rich Javascript applications (sometimes called One Page Applications) are a big thing, but what if you want to leverage Drupal on the backend, or have an existing site? Tools like Angular.JS and EmberJS are great when you have an API, but Drupal 7 doesn't really have an API layer. I'll explore the parts of a one page application and how to integrate it into either an existing or a new Drupal site, and the pitfalls that one must watch out for.
1 of 45
More Related Content
Single page apps with drupal 7
1. Single Page Apps with
Drupal 7
Chris
Tankersley
ZendCon
2015
ZendCon
2015
1
2. Who Am I
• PHP
Programmer
for
over
10
years
• Drupal
developer
for
5
years
• h>ps://github.com/dragonmantank
ZendCon
2015
2
3. What is a Single Page Application?
• An
applicaFon
that
loads
itself
in
in
a
single
page
ZendCon
2015
3
4. What is a Single Page Application?
• Loads
all
the
necessary
HTML,
CSS,
and
JS
needed
in
a
single
page
load
• Loads
all
the
necessary
HTML,
CSS,
and
JS
needed
to
bootstrap
an
applicaFon
in
a
single
page
load
ZendCon
2015
4
5. Traditional Application Workflow
ZendCon
2015
5
Browser
Server
User
requests
a
page
Server
returns
a
response
1) Server
gets
the
request
2) Server
calls
PHP
3) PHP
builds
the
HTML
Browser
Server
User
requests
a
page
Server
returns
a
response
1) Server
gets
the
request
2) Server
calls
PHP
3) PHP
builds
the
HTML
8. Single Page Application workflow
ZendCon
2015
8
Browser
Server
User
requests
a
page
Server
returns
a
response
1) Server
gets
the
request
2) Server
returns
base
HTML
Browser
requests
data
Server
returns
a
response
1) Server
gets
the
request
2) Server
calls
PHP
3) PHP
returns
JSON
Browser
requests
data
Server
returns
a
response
1) Server
gets
the
request
2) Server
calls
PHP
3) PHP
returns
JSON
…
9. SPAs are great!
• Reduce
server
load
• More
responsive
• Separates
the
server
and
the
front
end
• Make
the
front
end
people
do
all
the
work
ZendCon
2015
9
12. It’s not all great
• Users
have
to
have
JS
enabled
• SEO
SUUUUUUUUUUUUUUCKS
• This
will
probably
break
navigaFon
• This
will
probably
break
your
analyFcs
• Your
host
might
not
support
it
ZendCon
2015
12
16. Why do you want a Single Page
Application?
ZendCon
2015
16
17. Create an SPA if…
• You
want
a
more
desktop-‐like
experience
• A
lot
of
data
is
coming
and
going
• You
want/have
a
good
API
backend
• The
interface
lends
itself
to
being
an
SPA
ZendCon
2015
17
18. GMail makes sense
ZendCon
2015
18
h>p://3.bp.blogspot.com/-‐y96KrBvSbuQ/Tgu5oLmVZyI/AAAAAAAAAKE/EFkwE1ZIic8/s1600/threadlist-‐large.png
28. Data
ZendCon
2015
28
function node_schema() {
$schema['node'] = array(
'description' => 'The base table for nodes.',
'fields' => array(
'nid' => array(
'description' => 'The primary identifier for a node.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
// Defaults to NULL in order to avoid a brief period of potential
// deadlocks on the index.
'vid' => array(
'description' => 'The current {node_revision}.vid version identifier.',
'type' => 'int’,
37. What does it do?
“A
standardized
soluFon
of
integraFng
external
applicaFons
with
Drupal.
Service
callbacks
may
be
used
with
mulFple
interfaces
like
REST,
XMLRPC,
JSON,
JSON-‐RPC,
SOAP,
AMF,
etc.
This
allows
a
Drupal
site
to
provide
web
services
via
mulFple
interfaces
while
using
the
same
callback
code.”
ZendCon
2015
37
38. Services does a lot of heavy lifting for you
ZendCon
2015
38