SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
25 -27 April, 2014 http://camp2014.drupal.dn.ua
DrupalGap
Alexander Schedrov
How to create native application for mobile devices based on Drupal site
Schedrov Alexander
sanchiz
Drupal Developer at Trellon
What is DrupalGap?
Mobile Application Development Kit for
Drupal Websites
DrupalGap Module is the connection
between mobile applications and Drupal
websites
(c)drupalgap.org
Let's take a look, if it's true!
Support
• Themes, modules
• Blocks
• Menus
• Pages
• Entities
• Fields
• Forms
• Views
• Messages
• Services
• Geolocation
• Other tools
• You don't need a Objective-C and Java
developers
• For creating modules just need to write primitive
JS code
• Need to know how work Services
• Need to know how to create custom Services
endpoints and resources
To create powerful mobile application
How does PhoneGap work?
PhoneGap generates HTML, CSS
and JavaScript and make application
iOS and Android mobile
devices.
Apache Cordova provides access
via JavaScript to device
features such as the
Camera, GPS, File System,
Contacts, Compass, etc.
How mobile application interacts with Drupal Core
Services FTW!!!:)
Drupal site Application
Drupal requirements
services, rest_server, taxonomy, views_datasource,
views_json, drupalgap
!
Development environments
Google Chrome and the Ripple Emulator extension



OR
node.js

cordova

Java SDK for Android or xCode for iOS
File structure
modules
themes
settings.js
Debug
settings.js:
Drupal.settings.debug = true;
Logs in browser console:
dpm(json_result);
window.localStorage.clear();
drupalgap_alert(Fatal error', {
title: ‘Alert title',
buttonName: 'Done',
alertCallback: function() {}
});
drupalgap_set_message('Oh no!', 'error');
Themedrupalgap.settings.theme = 'amazing';
drupalgap.settings.blocks.amazing = {
header: {
title: {}
},
navigation: {
user_menu_anonymous:{
roles:{
value:['anonymous user'],
mode:'include'
}
},
user_menu_authenticated:{
roles:{
value:['authenticated user'],
mode:'include'
}
}
},
content: {
messages: {},
main: {}
},
footer: {
}
};
http://themeroller.jquerymobile.com
<div
id="{:drupalgap_page_id:}"
data-role="page">
{:header:}
{:navigation:}
{:content:}
{:footer:}
</div>
Need to add styles to
index.html
page.tpl.html
Creating module with page callback
• core_app (module folder)
• core_app.js (module file)
Drupal.modules.custom['core_app'] = {};
settings.js:
/**
* Implements hook_menu().
*/
function core_app_menu() {
var items = {};
items['homepage'] = {
title: 'DCDN Sandbox',
page_callback: 'core_app_homepage'
};
return items;
}
!
function core_app_homepage() {
var content = {};
content['homepage'] = {
markup: 'some markup'
};
return content;
}
Creating Menu
drupalgap.settings.menus['homepage_menu'] = {
links:[
{title:'News', path:'news'},
{title:'About', path:'node/1'},
{title:'Contact', path:'contact'},
{title:'Our team', path:'team'}
]
};
settings.js:
Important: here might be only real paths, not aliases
Creating Blocks
/**
* Implements hook_block_info().
*/
function core_app_block_info() {
var blocks = {
latest_news_block: {
delta: 'latest_news_block',
module: 'core_app'
}
};
return blocks;
}
!
/**
* Implements hook_block_view().
*/
function core_app_block_view(delta) {
var content = '';
if (delta == 'latest_news_block') {
content = '<h2>Latest news</h2>';
content += 'Some content...';
}
return content;
}
Block visibility
drupalgap.settings.blocks.amazing = {
content: {
homepage_menu: {
pages:{
value:['homepage'],
mode:'include'
}
},
latest_news_block: {
pages:{
value:['homepage'],
mode:'exclude'
}
},
users_block: {
pages:{
value:['node/*', 'user/*'],
mode:'include'
},
roles:{
value:['authenticated user'],
mode:'include'
}
},
},
};
!
Entity
node_load(1, {
success: function(node) {
}
});
!
node_save(node_array, {
success: function(node) {
}
});
!
node_delete(1, {
success: function(node) {
}
});
By default available pages:
• node/%, node/%/edit
• user/%, user/%/edit
• taxonomy/term/%, taxonomy/term/%/edit
• comment/%, comment/%/edit
Using Views
Need to create page with JSON data document format
(views_json module)
Displaying a View in mobile app
function core_team_menu() {
var items = {};
items['team'] = {
title: 'Our team',
page_callback: 'core_team_page'
}
return items;
}
function core_team_page() {
var content = {};
content['team'] = {
theme: 'view',
format: ‘ul', /* ul, ol, table, unformatted_list */
path: 'mobile/team_new', /* the path to the view in Drupal */
row_callback: 'core_team_page_row',
empty_callback: 'core_team_page_empty',
attributes: {
id: 'team-view'
}
};
return content;
}
!
function core_team_page_row(view, row) {
var output = '';
output += '<img class="team-image" src="' + row.field_photo + '">';
output += l(row.title, 'node/' + row.Nid);
return output;
}
!
function core_team_page_empty(view) {
return 'Sorry, no results.';
}
function core_app_voting_form(form, form_state) {
form.elements.name = {
type:'textfield',
title:'Name',
default_value: Drupal.user.name
};
form.elements.email = {
title:'Email Address',
type:'email',
required: true,
default_value: Drupal.user.mail
};
form.elements.categoty = {
title:'Category',
type:'select',
options:{
0:'Feedback',
1:'Question'
},
default_value:0
};
form.elements.comment = {
title:'Comment',
type:'textarea',
};
form.elements.rating = {
title:'Rating',
type:'radios',
required: true,
options:{
0:'0',
1:'+1',
},
default_value:3
};
form.elements.submit = {
type:'submit',
value:'Submit'
};
return form;
}
Forms
/**
* Implements hook_menu().
*/
function core_app_menu() {
var items = {};
items['vote-form'] = {
title: 'Voting form',
page_callback: 'drupalgap_get_form',
page_arguments:['core_app_voting_form']
};
return items;
}
/**
* Form's validation function (optional).
*/
function core_app_voting_form_validate(form, form_state) {
if (form_state.values.name == '') {
drupalgap_form_set_error('name', 'Name is required field.');
}
}
!
/**
* Form's submit function.
*/
function core_app_voting_form_submit(form, form_state) {
drupalgap_set_message('Thank you ' + form_state.values.name + '!');
drupalgap_goto('news');
}
Need additional functionality? You got it!
1. Create custom services resource in Drupal module

hook_services_resources();
2. Create custom services call in DrupalGap module

Drupal.services.call(options);
var output = '';
Drupal.services.call({
method: 'POST',
path: 'news.json',
data: args,
success: function(result) {
output = '';
$.each(result, function(i, node) {
output += node.title;
});
}
});
Demo
Links	
• http://api.drupalgap.org/
• http://www.drupalgap.org/
• http://www.drupalgap.org/troubleshoot
• http://www.drupalgap.org/node/211
• https://drupal.org/node/2015065
Troubleshooting
THANK YOU!
!
Email: alexander.schedrov@gmail.com
Twitter: @alexschedrov
FB: schedrov
http://sanchiz.net

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APICaldera Labs
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLhouzman
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGapAlex S
 
Docker, Ansible and Symfony micro-kernel
Docker, Ansible and Symfony micro-kernelDocker, Ansible and Symfony micro-kernel
Docker, Ansible and Symfony micro-kernelDrupalCamp Kyiv
 
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ..."Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...DrupalCamp Kyiv
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLarry Cai
 
Making your Angular.js Application accessible
Making your Angular.js Application accessibleMaking your Angular.js Application accessible
Making your Angular.js Application accessibleDirk Ginader
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015Chang W. Doh
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
Room with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.jsRoom with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.jsZachary Klein
 
Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8Pantheon
 
Introduction to modern front-end with Vue.js
Introduction to modern front-end with Vue.jsIntroduction to modern front-end with Vue.js
Introduction to modern front-end with Vue.jsmonterail
 
Grails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to OrbitGrails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to OrbitZachary Klein
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.xJoão Ventura
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Ovadiah Myrgorod
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIBrian Hogg
 
Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Acquia
 

Was ist angesagt? (20)

Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
 
WordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQLWordPress 2017 with VueJS and GraphQL
WordPress 2017 with VueJS and GraphQL
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Nuxtjs cheat-sheet
Nuxtjs cheat-sheetNuxtjs cheat-sheet
Nuxtjs cheat-sheet
 
Docker, Ansible and Symfony micro-kernel
Docker, Ansible and Symfony micro-kernelDocker, Ansible and Symfony micro-kernel
Docker, Ansible and Symfony micro-kernel
 
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ..."Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
 
Making your Angular.js Application accessible
Making your Angular.js Application accessibleMaking your Angular.js Application accessible
Making your Angular.js Application accessible
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Room with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.jsRoom with a Vue - Introduction to Vue.js
Room with a Vue - Introduction to Vue.js
 
Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8
 
The Heron Mapping Client
The Heron Mapping ClientThe Heron Mapping Client
The Heron Mapping Client
 
Introduction to modern front-end with Vue.js
Introduction to modern front-end with Vue.jsIntroduction to modern front-end with Vue.js
Introduction to modern front-end with Vue.js
 
Vue business first
Vue business firstVue business first
Vue business first
 
Grails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to OrbitGrails Launchpad - From Ground Zero to Orbit
Grails Launchpad - From Ground Zero to Orbit
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8Using Backbone.js with Drupal 7 and 8
Using Backbone.js with Drupal 7 and 8
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8Everything You Need to Know About the Top Changes in Drupal 8
Everything You Need to Know About the Top Changes in Drupal 8
 

Andere mochten auch

Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Alex S
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIAlex S
 
Drupal Training Days 2017 - Drupal 8 basic functions.
Drupal Training Days 2017 - Drupal 8 basic functions.Drupal Training Days 2017 - Drupal 8 basic functions.
Drupal Training Days 2017 - Drupal 8 basic functions.Alex S
 
Using Drupal as a backend for Android app
Using Drupal as a backend for Android appUsing Drupal as a backend for Android app
Using Drupal as a backend for Android appBorort Sort
 
Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011
Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011
Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011camp_drupal_ua
 
Drupal 8 what to wait from
Drupal 8   what to wait fromDrupal 8   what to wait from
Drupal 8 what to wait fromAndrii Podanenko
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011camp_drupal_ua
 
Історія, теорія та використання CMS Drupal
Історія, теорія та використання CMS DrupalІсторія, теорія та використання CMS Drupal
Історія, теорія та використання CMS DrupalIgor Bronovskyy
 
Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Andrii Podanenko
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxAndrii Podanenko
 
Infographic : Enterprise Mobility Solutions Tree
Infographic : Enterprise Mobility Solutions TreeInfographic : Enterprise Mobility Solutions Tree
Infographic : Enterprise Mobility Solutions TreeMobiloitte
 
Christmas Apps For iOS
Christmas Apps For iOSChristmas Apps For iOS
Christmas Apps For iOSFluperOfficial
 
Головні Принципи Автоматизації
Головні Принципи АвтоматизаціїГоловні Принципи Автоматизації
Головні Принципи АвтоматизаціїAndrii Podanenko
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.Andrii Podanenko
 
Trends, Challenges & Solution For Mobile App UX Design
Trends, Challenges & Solution For Mobile App UX DesignTrends, Challenges & Solution For Mobile App UX Design
Trends, Challenges & Solution For Mobile App UX DesignHu yang
 
Mobile App Development Challenges
Mobile App Development ChallengesMobile App Development Challenges
Mobile App Development ChallengesMobinex
 
MobiSharks [Mobile Technology Agency]
MobiSharks [Mobile Technology Agency]MobiSharks [Mobile Technology Agency]
MobiSharks [Mobile Technology Agency]Liliya Mukhametova
 
Challenges of a mobile application developer
Challenges of a mobile application developerChallenges of a mobile application developer
Challenges of a mobile application developerWilliam S. Rodriguez
 

Andere mochten auch (20)

Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds API
 
Drupal Training Days 2017 - Drupal 8 basic functions.
Drupal Training Days 2017 - Drupal 8 basic functions.Drupal Training Days 2017 - Drupal 8 basic functions.
Drupal Training Days 2017 - Drupal 8 basic functions.
 
Using Drupal as a backend for Android app
Using Drupal as a backend for Android appUsing Drupal as a backend for Android app
Using Drupal as a backend for Android app
 
Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011
Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011
Vlad Savitsky.Modules parade.DrupalCamp Kyiv 2011
 
Drupal 8 what to wait from
Drupal 8   what to wait fromDrupal 8   what to wait from
Drupal 8 what to wait from
 
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
Andriy Podanenko.Drupal database api.DrupalCamp Kyiv 2011
 
Історія, теорія та використання CMS Drupal
Історія, теорія та використання CMS DrupalІсторія, теорія та використання CMS Drupal
Історія, теорія та використання CMS Drupal
 
Start using vagrant now!
Start using vagrant now!Start using vagrant now!
Start using vagrant now!
 
Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration Toolbox
 
Infographic : Enterprise Mobility Solutions Tree
Infographic : Enterprise Mobility Solutions TreeInfographic : Enterprise Mobility Solutions Tree
Infographic : Enterprise Mobility Solutions Tree
 
Christmas Apps For iOS
Christmas Apps For iOSChristmas Apps For iOS
Christmas Apps For iOS
 
Головні Принципи Автоматизації
Головні Принципи АвтоматизаціїГоловні Принципи Автоматизації
Головні Принципи Автоматизації
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.
 
Trends, Challenges & Solution For Mobile App UX Design
Trends, Challenges & Solution For Mobile App UX DesignTrends, Challenges & Solution For Mobile App UX Design
Trends, Challenges & Solution For Mobile App UX Design
 
Mobile App Development Challenges
Mobile App Development ChallengesMobile App Development Challenges
Mobile App Development Challenges
 
MobiSharks [Mobile Technology Agency]
MobiSharks [Mobile Technology Agency]MobiSharks [Mobile Technology Agency]
MobiSharks [Mobile Technology Agency]
 
Challenges of a mobile application developer
Challenges of a mobile application developerChallenges of a mobile application developer
Challenges of a mobile application developer
 
Ux,UI & wireframes
Ux,UI & wireframesUx,UI & wireframes
Ux,UI & wireframes
 

Ähnlich wie DrupalGap. How to create native application for mobile devices based on Drupal site - DrupalCamp Donetsk 2014

Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinADCI Solutions
 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module developmentdrupalindia
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source ApplittleMAS
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest
 
Headless Drupal en pratique
Headless Drupal en pratiqueHeadless Drupal en pratique
Headless Drupal en pratiqueSimon Morvan
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksmwbrooks
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverSpike Brehm
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module DevelopmentSumeet Pareek
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers dssprakash
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Filippo Matteo Riggio
 
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginDrupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginAcquia
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJSGregor Woiwode
 
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)Konstantin Komelin
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-final20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-finalDavid Lapsley
 

Ähnlich wie DrupalGap. How to create native application for mobile devices based on Drupal site - DrupalCamp Donetsk 2014 (20)

Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton Shubkin
 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module development
 
Migrations
MigrationsMigrations
Migrations
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source App
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
 
Headless Drupal en pratique
Headless Drupal en pratiqueHeadless Drupal en pratique
Headless Drupal en pratique
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginDrupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
 
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
#D8CX: Upgrade your modules to Drupal 8 (Part 1 and 2)
 
#D8 cx: upgrade your modules to drupal 8
#D8 cx: upgrade your modules to drupal 8 #D8 cx: upgrade your modules to drupal 8
#D8 cx: upgrade your modules to drupal 8
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-final20141002 delapsley-socalangularjs-final
20141002 delapsley-socalangularjs-final
 

Kürzlich hochgeladen

Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 

Kürzlich hochgeladen (17)

young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 

DrupalGap. How to create native application for mobile devices based on Drupal site - DrupalCamp Donetsk 2014

  • 1. 25 -27 April, 2014 http://camp2014.drupal.dn.ua DrupalGap Alexander Schedrov How to create native application for mobile devices based on Drupal site
  • 3. What is DrupalGap? Mobile Application Development Kit for Drupal Websites DrupalGap Module is the connection between mobile applications and Drupal websites (c)drupalgap.org Let's take a look, if it's true!
  • 4. Support • Themes, modules • Blocks • Menus • Pages • Entities • Fields • Forms • Views • Messages • Services • Geolocation • Other tools
  • 5.
  • 6. • You don't need a Objective-C and Java developers • For creating modules just need to write primitive JS code • Need to know how work Services • Need to know how to create custom Services endpoints and resources To create powerful mobile application
  • 7. How does PhoneGap work? PhoneGap generates HTML, CSS and JavaScript and make application iOS and Android mobile devices. Apache Cordova provides access via JavaScript to device features such as the Camera, GPS, File System, Contacts, Compass, etc.
  • 8. How mobile application interacts with Drupal Core Services FTW!!!:) Drupal site Application
  • 9. Drupal requirements services, rest_server, taxonomy, views_datasource, views_json, drupalgap ! Development environments Google Chrome and the Ripple Emulator extension
 
 OR node.js
 cordova
 Java SDK for Android or xCode for iOS
  • 11. Debug settings.js: Drupal.settings.debug = true; Logs in browser console: dpm(json_result); window.localStorage.clear(); drupalgap_alert(Fatal error', { title: ‘Alert title', buttonName: 'Done', alertCallback: function() {} }); drupalgap_set_message('Oh no!', 'error');
  • 12. Themedrupalgap.settings.theme = 'amazing'; drupalgap.settings.blocks.amazing = { header: { title: {} }, navigation: { user_menu_anonymous:{ roles:{ value:['anonymous user'], mode:'include' } }, user_menu_authenticated:{ roles:{ value:['authenticated user'], mode:'include' } } }, content: { messages: {}, main: {} }, footer: { } }; http://themeroller.jquerymobile.com <div id="{:drupalgap_page_id:}" data-role="page"> {:header:} {:navigation:} {:content:} {:footer:} </div> Need to add styles to index.html page.tpl.html
  • 13. Creating module with page callback • core_app (module folder) • core_app.js (module file) Drupal.modules.custom['core_app'] = {}; settings.js: /** * Implements hook_menu(). */ function core_app_menu() { var items = {}; items['homepage'] = { title: 'DCDN Sandbox', page_callback: 'core_app_homepage' }; return items; } ! function core_app_homepage() { var content = {}; content['homepage'] = { markup: 'some markup' }; return content; }
  • 14. Creating Menu drupalgap.settings.menus['homepage_menu'] = { links:[ {title:'News', path:'news'}, {title:'About', path:'node/1'}, {title:'Contact', path:'contact'}, {title:'Our team', path:'team'} ] }; settings.js: Important: here might be only real paths, not aliases
  • 15. Creating Blocks /** * Implements hook_block_info(). */ function core_app_block_info() { var blocks = { latest_news_block: { delta: 'latest_news_block', module: 'core_app' } }; return blocks; } ! /** * Implements hook_block_view(). */ function core_app_block_view(delta) { var content = ''; if (delta == 'latest_news_block') { content = '<h2>Latest news</h2>'; content += 'Some content...'; } return content; } Block visibility drupalgap.settings.blocks.amazing = { content: { homepage_menu: { pages:{ value:['homepage'], mode:'include' } }, latest_news_block: { pages:{ value:['homepage'], mode:'exclude' } }, users_block: { pages:{ value:['node/*', 'user/*'], mode:'include' }, roles:{ value:['authenticated user'], mode:'include' } }, }, }; !
  • 16. Entity node_load(1, { success: function(node) { } }); ! node_save(node_array, { success: function(node) { } }); ! node_delete(1, { success: function(node) { } }); By default available pages: • node/%, node/%/edit • user/%, user/%/edit • taxonomy/term/%, taxonomy/term/%/edit • comment/%, comment/%/edit
  • 17. Using Views Need to create page with JSON data document format (views_json module) Displaying a View in mobile app function core_team_menu() { var items = {}; items['team'] = { title: 'Our team', page_callback: 'core_team_page' } return items; }
  • 18. function core_team_page() { var content = {}; content['team'] = { theme: 'view', format: ‘ul', /* ul, ol, table, unformatted_list */ path: 'mobile/team_new', /* the path to the view in Drupal */ row_callback: 'core_team_page_row', empty_callback: 'core_team_page_empty', attributes: { id: 'team-view' } }; return content; } ! function core_team_page_row(view, row) { var output = ''; output += '<img class="team-image" src="' + row.field_photo + '">'; output += l(row.title, 'node/' + row.Nid); return output; } ! function core_team_page_empty(view) { return 'Sorry, no results.'; }
  • 19.
  • 20. function core_app_voting_form(form, form_state) { form.elements.name = { type:'textfield', title:'Name', default_value: Drupal.user.name }; form.elements.email = { title:'Email Address', type:'email', required: true, default_value: Drupal.user.mail }; form.elements.categoty = { title:'Category', type:'select', options:{ 0:'Feedback', 1:'Question' }, default_value:0 }; form.elements.comment = { title:'Comment', type:'textarea', }; form.elements.rating = { title:'Rating', type:'radios', required: true, options:{ 0:'0', 1:'+1', }, default_value:3 }; form.elements.submit = { type:'submit', value:'Submit' }; return form; } Forms
  • 21. /** * Implements hook_menu(). */ function core_app_menu() { var items = {}; items['vote-form'] = { title: 'Voting form', page_callback: 'drupalgap_get_form', page_arguments:['core_app_voting_form'] }; return items; } /** * Form's validation function (optional). */ function core_app_voting_form_validate(form, form_state) { if (form_state.values.name == '') { drupalgap_form_set_error('name', 'Name is required field.'); } } ! /** * Form's submit function. */ function core_app_voting_form_submit(form, form_state) { drupalgap_set_message('Thank you ' + form_state.values.name + '!'); drupalgap_goto('news'); }
  • 22. Need additional functionality? You got it! 1. Create custom services resource in Drupal module
 hook_services_resources(); 2. Create custom services call in DrupalGap module
 Drupal.services.call(options); var output = ''; Drupal.services.call({ method: 'POST', path: 'news.json', data: args, success: function(result) { output = ''; $.each(result, function(i, node) { output += node.title; }); } });
  • 23. Demo
  • 24. Links • http://api.drupalgap.org/ • http://www.drupalgap.org/ • http://www.drupalgap.org/troubleshoot • http://www.drupalgap.org/node/211 • https://drupal.org/node/2015065 Troubleshooting
  • 25. THANK YOU! ! Email: alexander.schedrov@gmail.com Twitter: @alexschedrov FB: schedrov http://sanchiz.net