SlideShare a Scribd company logo
1 of 26
Download to read offline
GETTING STARTED WITH 
DRUPALGAP 
Schedrov Alexander - sanchiz
SCHEDROV ALEXANDER 
AKA 
SANCHIZ 
Lead Drupal Developer at Trellon 
Maintainer: 
• pathauto_i18n 
• user_profile_comment 
• DrupalGapManager 
https://github.com/Sanchiz/DrupalGapManager 
Participant: 
• crm_core 
• relation_lists
MOBILE WEBSITE TRAFFIC 
Percentage of website traffic from mobile devices 
32 
24 
16 
8 
0 
30.0% 32.0% 29.0% 28.0% 
23.9% 
Q1 2013 Q2 2013 Q3 2013 Q4 2013 Q1 2014
MEET DRUPALGAP 
• Created by Tyler Frankenstein 
• First release Feb 25, 2012 ~100 lines 
• Currently ~10,000 lines
DRUPALGAP 
Drupal module 
hosted on d.org 
It's connection 
between mobile 
applications and 
Drupal websites via 
web Services. 
Development Kit hosted 
on GitHub 
Developers can create 
custom multi-platform 
mobile applications that 
communicate with their 
Drupal websites.
REGULAR SITE 
Website 
+ 
Responsive 
Website
WHY DO YOU NEED MOBILE 
APPLICATION? 
Our mobile phone have features which don't 
have our regular devices! 
! 
DrupalGap features: 
You don't need a Objective-C and Java developers. 
If you know how to build Drupal modules and 
know JavaScript - Welcome to DrupalGap 
developers.
HOW IT WORKS? 
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.
REQUIREMENTS 
DRUPAL 
Services, Rest_server, Views_datasource, Views_json, Drupalgap 
! 
DEVELOPMENT ENVIRONMENTS 
Google Chrome and the Ripple Emulator extension 
OR 
node.js 
cordova(node.js package) 
Java SDK for Android or xCode for iOS
DRUPALGAP INHERITS DRUPAL 
DEVELOPER CONCEPTS 
• Themes, modules 
• Blocks 
• Menus 
• Pages 
• Entities 
• Fields 
• Forms 
• Views 
• Messages 
• Services 
• Other Drupal 
tools
2 FOR DEALS 
https://play.google.com/store/apps/details?id=com.twofordeals
BETTRACKS 
https://bettracks.co.uk
EXTENSIBLE WITH CONTRIB MODULES 
• Force Authentication 
• Telephone 
• Address Field 
• AmazonS3 
• AudioField 
• Colorbox 
• Commerce 
• Commerce DrupalGap Stripe 
• Date 
• Email Registration 
• Entity reference 
• Fivestar 
• Flag 
• Geofield 
• GeoTracker 
• Link 
• Location 
• LoginToboggan 
• Pathfix 
• Push Notifications 
• Rate 
• Services Menu 
• Shadowbox 
• User registration password 
• Voting API 
• Webform 
http://www.drupalgap.org/project/modules
DRUPALGAP MANAGER 
is a command-line tool and interface for DrupalGap 
https://github.com/Sanchiz/DrupalGapManager 
https://www.npmjs.org/package/dgm
EVEN MORE…. INTEGRATION WITH COMMERCE 
http://tylerfrankenstein.com/code/build-mobile-app-sell-products-with-drupal
HOOKS IN 7.X-1.0-RC3 
*_404 
*_assemble_form_state_into_field 
*_block_info 
*_block_view 
*_deviceready 
*_drupalgap_goto_post_process 
*_drupalgap_goto_preprocess 
*_entity_post_render_content 
*_entity_post_render_field 
*_field_formatter_view 
*_field_widget_form 
*_form_alter 
*_image_path_alter 
*_install 
*_menu 
*_services_postprocess 
*_services_preprocess 
*_services_request_postprocess_alter 
*_services_request_pre_postprocess_alter 
*_services_success 
and custom forms 
http://api.drupalgap.org
FILE STRUCTURE 
modules 
themes 
settings.js
• core_app (module folder) 
• core_app.js (module file) 
/** 
* Implements hook_menu(). 
*/ 
function core_app_menu() { 
var items = {}; 
items['homepage'] = { 
title: 'New Sandbox', 
page_callback: 'core_app_homepage' 
}; 
return items; 
} 
! 
function core_app_homepage() { 
var content = {}; 
content['homepage'] = { 
markup: 'some markup' 
}; 
return content; 
settings.js: 
} 
Drupal.modules.custom['core_app'] = {};
OR CUSTOM BLOCK? 
/** 
* 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; 
} 
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' 
} 
}, 
}, 
};
function core_app_voting_form(form, form_state) { 
form.elements.name = { 
OR CUSTOM FORM? 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; 
}
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; 
}); 
} 
});
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.'; 
}
DEMO
THANK YOU! 
https://www.drupal.org/u/sanchiz 
https://github.com/Sanchiz 
http://sanchiz.net 
Email: alexander.schedrov@gmail.com 
Twitter: @alexschedrov

More Related Content

What's hot

Amsterdam.js talk: node webkit
Amsterdam.js talk: node webkitAmsterdam.js talk: node webkit
Amsterdam.js talk: node webkit
Fabian Jakobs
 
10 New Things You Can Do with Drupal 8 Out-of-the-Box
10 New Things You Can Do with Drupal 8 Out-of-the-Box10 New Things You Can Do with Drupal 8 Out-of-the-Box
10 New Things You Can Do with Drupal 8 Out-of-the-Box
Suzanne Dergacheva
 

What's hot (20)

Docker, Ansible and Symfony micro-kernel
Docker, Ansible and Symfony micro-kernelDocker, Ansible and Symfony micro-kernel
Docker, Ansible and Symfony micro-kernel
 
Don’t fight with windmills. Upgrade path tool from OpenY distro - Igor Karpil...
Don’t fight with windmills. Upgrade path tool from OpenY distro - Igor Karpil...Don’t fight with windmills. Upgrade path tool from OpenY distro - Igor Karpil...
Don’t fight with windmills. Upgrade path tool from OpenY distro - Igor Karpil...
 
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
 
Composer and deployer for enterprise
Composer and deployer for enterpriseComposer and deployer for enterprise
Composer and deployer for enterprise
 
Building Mobile Applications with Ionic
Building Mobile Applications with IonicBuilding Mobile Applications with Ionic
Building Mobile Applications with Ionic
 
Amsterdam.js talk: node webkit
Amsterdam.js talk: node webkitAmsterdam.js talk: node webkit
Amsterdam.js talk: node webkit
 
10 New Things You Can Do with Drupal 8 Out-of-the-Box
10 New Things You Can Do with Drupal 8 Out-of-the-Box10 New Things You Can Do with Drupal 8 Out-of-the-Box
10 New Things You Can Do with Drupal 8 Out-of-the-Box
 
Passo a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaPasso a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel Híbrida
 
Building a Single Page Application with VueJS
Building a Single Page Application with VueJSBuilding a Single Page Application with VueJS
Building a Single Page Application with VueJS
 
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
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
The Heron Mapping Client
The Heron Mapping ClientThe Heron Mapping Client
The Heron Mapping Client
 
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
 
The Heron Mapping Client
The Heron Mapping ClientThe Heron Mapping Client
The Heron Mapping Client
 
Untangling the web9
Untangling the web9Untangling the web9
Untangling the web9
 
Making your Angular.js Application accessible
Making your Angular.js Application accessibleMaking your Angular.js Application accessible
Making your Angular.js Application accessible
 
JavaScript All The Things
JavaScript All The ThingsJavaScript All The Things
JavaScript All The Things
 
Drupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and FlickrDrupal Recipes: Building Image Galleries with jQuery and Flickr
Drupal Recipes: Building Image Galleries with jQuery and Flickr
 
[drupalday2017] - Speed-up your Drupal instance!
[drupalday2017] - Speed-up your Drupal instance![drupalday2017] - Speed-up your Drupal instance!
[drupalday2017] - Speed-up your Drupal instance!
 

Viewers also liked

Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds API
Alex S
 

Viewers also liked (6)

Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
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.
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Scaling and sharing: Building custom drupal distributions for federated organ...
Scaling and sharing: Building custom drupal distributions for federated organ...Scaling and sharing: Building custom drupal distributions for federated organ...
Scaling and sharing: Building custom drupal distributions for federated organ...
 

Similar to Getting Started with DrupalGap

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
camp_drupal_ua
 
Spark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolaSpark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboola
tsliwowicz
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
mwbrooks
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
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
ADCI Solutions
 

Similar to Getting Started with DrupalGap (20)

DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
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
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)
 
Drupal, Android and iPhone
Drupal, Android and iPhoneDrupal, Android and iPhone
Drupal, Android and iPhone
 
Headless Drupal en pratique
Headless Drupal en pratiqueHeadless Drupal en pratique
Headless Drupal en pratique
 
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
 
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
 
Migrations
MigrationsMigrations
Migrations
 
Made for Mobile - Let Office 365 Power Your Mobile Apps
Made for Mobile - Let Office 365 Power Your Mobile AppsMade for Mobile - Let Office 365 Power Your Mobile Apps
Made for Mobile - Let Office 365 Power Your Mobile Apps
 
Spark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboolaSpark on Dataproc - Israel Spark Meetup at taboola
Spark on Dataproc - Israel Spark Meetup at taboola
 
BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!
 
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
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Migrating data to drupal 8
Migrating data to drupal 8Migrating data to drupal 8
Migrating data to drupal 8
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Html5 Overview
Html5 OverviewHtml5 Overview
Html5 Overview
 
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
 

Recently uploaded

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (6)

Mobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s ToolsMobile Application Development-Android and It’s Tools
Mobile Application Development-Android and It’s Tools
 
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
Satara Call girl escort *74796//13122* Call me punam call girls 24*7hour avai...
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
Android Application Components with Implementation & Examples
Android Application Components with Implementation & ExamplesAndroid Application Components with Implementation & Examples
Android Application Components with Implementation & Examples
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312Mobile App Penetration Testing Bsides312
Mobile App Penetration Testing Bsides312
 

Getting Started with DrupalGap

  • 1. GETTING STARTED WITH DRUPALGAP Schedrov Alexander - sanchiz
  • 2. SCHEDROV ALEXANDER AKA SANCHIZ Lead Drupal Developer at Trellon Maintainer: • pathauto_i18n • user_profile_comment • DrupalGapManager https://github.com/Sanchiz/DrupalGapManager Participant: • crm_core • relation_lists
  • 3. MOBILE WEBSITE TRAFFIC Percentage of website traffic from mobile devices 32 24 16 8 0 30.0% 32.0% 29.0% 28.0% 23.9% Q1 2013 Q2 2013 Q3 2013 Q4 2013 Q1 2014
  • 4. MEET DRUPALGAP • Created by Tyler Frankenstein • First release Feb 25, 2012 ~100 lines • Currently ~10,000 lines
  • 5. DRUPALGAP Drupal module hosted on d.org It's connection between mobile applications and Drupal websites via web Services. Development Kit hosted on GitHub Developers can create custom multi-platform mobile applications that communicate with their Drupal websites.
  • 6. REGULAR SITE Website + Responsive Website
  • 7. WHY DO YOU NEED MOBILE APPLICATION? Our mobile phone have features which don't have our regular devices! ! DrupalGap features: You don't need a Objective-C and Java developers. If you know how to build Drupal modules and know JavaScript - Welcome to DrupalGap developers.
  • 8.
  • 9. HOW IT WORKS? 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.
  • 10. REQUIREMENTS DRUPAL Services, Rest_server, Views_datasource, Views_json, Drupalgap ! DEVELOPMENT ENVIRONMENTS Google Chrome and the Ripple Emulator extension OR node.js cordova(node.js package) Java SDK for Android or xCode for iOS
  • 11. DRUPALGAP INHERITS DRUPAL DEVELOPER CONCEPTS • Themes, modules • Blocks • Menus • Pages • Entities • Fields • Forms • Views • Messages • Services • Other Drupal tools
  • 12. 2 FOR DEALS https://play.google.com/store/apps/details?id=com.twofordeals
  • 14. EXTENSIBLE WITH CONTRIB MODULES • Force Authentication • Telephone • Address Field • AmazonS3 • AudioField • Colorbox • Commerce • Commerce DrupalGap Stripe • Date • Email Registration • Entity reference • Fivestar • Flag • Geofield • GeoTracker • Link • Location • LoginToboggan • Pathfix • Push Notifications • Rate • Services Menu • Shadowbox • User registration password • Voting API • Webform http://www.drupalgap.org/project/modules
  • 15. DRUPALGAP MANAGER is a command-line tool and interface for DrupalGap https://github.com/Sanchiz/DrupalGapManager https://www.npmjs.org/package/dgm
  • 16. EVEN MORE…. INTEGRATION WITH COMMERCE http://tylerfrankenstein.com/code/build-mobile-app-sell-products-with-drupal
  • 17. HOOKS IN 7.X-1.0-RC3 *_404 *_assemble_form_state_into_field *_block_info *_block_view *_deviceready *_drupalgap_goto_post_process *_drupalgap_goto_preprocess *_entity_post_render_content *_entity_post_render_field *_field_formatter_view *_field_widget_form *_form_alter *_image_path_alter *_install *_menu *_services_postprocess *_services_preprocess *_services_request_postprocess_alter *_services_request_pre_postprocess_alter *_services_success and custom forms http://api.drupalgap.org
  • 18. FILE STRUCTURE modules themes settings.js
  • 19. • core_app (module folder) • core_app.js (module file) /** * Implements hook_menu(). */ function core_app_menu() { var items = {}; items['homepage'] = { title: 'New Sandbox', page_callback: 'core_app_homepage' }; return items; } ! function core_app_homepage() { var content = {}; content['homepage'] = { markup: 'some markup' }; return content; settings.js: } Drupal.modules.custom['core_app'] = {};
  • 20. OR CUSTOM BLOCK? /** * 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; } 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' } }, }, };
  • 21. function core_app_voting_form(form, form_state) { form.elements.name = { OR CUSTOM FORM? 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; }
  • 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. 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; }
  • 24. 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.'; }
  • 25. DEMO
  • 26. THANK YOU! https://www.drupal.org/u/sanchiz https://github.com/Sanchiz http://sanchiz.net Email: alexander.schedrov@gmail.com Twitter: @alexschedrov