SlideShare a Scribd company logo
1 of 24
Download to read offline
Render API in Drupal7


Shmaleniuk Nikolay
n.shmaleniuk@gmail.com
Gold Sponsor of
DrupalCamp Kyiv 2011
Silver Sponsors of
DrupalCamp Kyiv 2011
Render API introduction

Render API similar to the work of the Form API.
1. The system collects an array which contains all the
   necessary data
– Array data converted to html and displayed
Main hooks

• hook_page_build
 add items to the page
• hook_page_alter
 override the output of all page elements before output
dsm(hook_page_alter_data)
Render API theming

• #theme - theme_function to be called
• #arg_1, #arg_2 - arguments with prefix "#", necessary for the
  theme function
The advantages of using

• One general system of generating output data
• All html on the page, can be easily overridden by using a one
  hook
• Reusability code. Reusability the menu callbacks or blocks
  for the their tasks (eg AJAX replies)
• Caching
3 types of element

1. Standerd element, key #type (hook_element_info())
2. Text data, key #markup
3. Theme element, key #theme
Example, node.tpl.php
render(), show(), hide()

  <?php
   hide($content['comments']);
   hide($content['links']);
   print render($content);
  ?>

  <?php if (!empty($content['links'])): ?>
   <div class="links"><?php print render($content['links']); ?>

   </div>
  <?php endif; ?>

  <?php print render($content['comments']); ?>
Example
// Drupal 6.
function my_module_show_same_items() {
  $items = array('item 1', 'item 2', 'item 3');
  $out = theme('item_list', $items);
  return $out;
}

// Drupal 7.
function my_module_show_some_items() {
  $items = array('item 1', 'item 2', 'item 3');
  $build = array(
    'items' => array('#theme' => 'item_list', '#items' => $items),
  );
  return $build;
}
Example
function theme_pager_link($variables) {
  $var_text = $variables['var'];
  $var_page_new = $variables['var_2'];
... }

function my_module_show_some_text() {
  $item = array(
    'items' => array(
       '#theme' => 'pager_link',
       '#var' => 'some text',
       '#var_2' => '...',
    ),
  );
  return $item;
}
The array keys Render API
•   #access - TRUE or FALSE
•   #type - str
•   #printed - TRUE or FALSE
•   #cache - array()
•   #theme - str
•   #theme_wrappers - array()
•   #pre_render - array()
•   #post_render - array()
•   #attached - array()
•   #prefix, #suffix - str
Sequence of actions drupal_render()

1. Checking #access и #printed
2. Checking the cache
3. Loading the default item (if #type)
4. Call #pre_render
5. Call #theme
6. Call #theme_wrappers
7. Call #post_render
8. Load attached recurses #attached (JS, CSS, etc.)
9. If #cache set, the write cache
10.return #prefix . $out . #suffix;
Attached recurses, JS/CSS files

$form['#attached']['css'] = array(
  drupal_get_path('module', 'ajax_example') .
'/ajax_example.css',
);

$form['#attached']['js'] = array(
  drupal_get_path('module', 'ajax_example') . '/ajax_example.js',
);
Attached recurses, JS settings

$settings = array('id' => 'mymodule-element-1');

$form['#attached']['js'][] = array(
  'data' => array('mymodule' => $settings),
  'type' => 'setting',
);
Attached recurses, http header
and library
$form['#attached']['drupal_add_http_header'] = array(
  array('Content-Type', 'application/rss+xml; charset=utf-8'),
);

$form['#attached']['library'][] = array('system', 'drupal.ajax');
Caching

  $build = array(
    'items' => array(
        '#theme' => 'item_list',
        '#items' => $items,
'#cache' => array(
            'keys'        => array('example', 'cache'),
            'bin'         => 'cache',
            'expire'      => time() + $interval,
            'granularity' => DRUPAL_CACHE_PER_PAGE |
                             DRUPAL_CACHE_PER_ROLE,
        ),
     ),
  );
Caching

$items = module_load_item_list();
$build = array(
  'items' => array(
      '#theme' => 'item_list',
      '#items' => $items,
      '#cache' => array(
          'keys'        => array('example', 'cache'),
          'bin'         => 'cache',
          'expire'      => time() + $interval,
          'granularity' => DRUPAL_CACHE_PER_PAGE |
                           DRUPAL_CACHE_PER_ROLE,
      ),
   ),
);
Caching
$build = array(
  'items' => array(
      '#theme' => 'item_list',
      '#pre_render' => array( 'module_load_item_list'),
      '#items' => array(),
      '#cache' => array(
          'keys'        => array('example', 'cache'),
          'granularity' => DRUPAL_CACHE_PER_PAGE,
      ),
   ),
);
function module_load_item_list(&$element) {
  $element['#items'] = module_load_item_list();
}
• Render Arrays in Drupal
  http://drupal.org/node/930760
• Examples
  http://drupal.org/project/examples



Shmaleniuk Nikolay
n.shmaleniuk@gmail.com

More Related Content

What's hot

The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design PatternsHugo Hamon
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & RESTHugo Hamon
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway ichikaway
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usagePavel Makhrinsky
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3markstory
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixturesBill Chang
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APISix Apart KK
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPVineet Kumar Saini
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHPVineet Kumar Saini
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 

What's hot (20)

The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design Patterns
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
 
Drupal Field API. Practical usage
Drupal Field API. Practical usageDrupal Field API. Practical usage
Drupal Field API. Practical usage
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
 
CakeFest 2013 keynote
CakeFest 2013 keynoteCakeFest 2013 keynote
CakeFest 2013 keynote
 
Doctrine fixtures
Doctrine fixturesDoctrine fixtures
Doctrine fixtures
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
MTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new APIMTDDC 2010.2.5 Tokyo - Brand new API
MTDDC 2010.2.5 Tokyo - Brand new API
 
Drupal Render API
Drupal Render APIDrupal Render API
Drupal Render API
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Database api
Database apiDatabase api
Database api
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Wp query
Wp queryWp query
Wp query
 

Viewers also liked

Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011
Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011
Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011camp_drupal_ua
 
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011camp_drupal_ua
 
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011Vlad Savitsky
 
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
 
Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011
Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011
Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011camp_drupal_ua
 
Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011
Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011
Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011camp_drupal_ua
 
Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011
Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011
Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011camp_drupal_ua
 

Viewers also liked (7)

Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011
Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011
Pavel Makhrinsky.Field API.DrupalCamp Kyiv 2011
 
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
 
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
Oleg Natalushko. Drupal server anatomy. DrupalCamp Kyiv 2011
 
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
 
Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011
Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011
Grigory Naumovets.Multilingual sites.DrupalCamp Kyiv 2011
 
Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011
Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011
Eugene Poltorakov.HTML 5 and drupal.DrupalCamp Kiev 2011
 
Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011
Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011
Vadim Mirgorod.OpenAcaDept.DrupalCamp Kyiv 2011
 

Similar to Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011

DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7chuvainc
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmdiKlaus
 
Let's write secure Drupal code!
Let's write secure Drupal code!Let's write secure Drupal code!
Let's write secure Drupal code!Balázs Tatár
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutesBarang CK
 
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 MinutesAzim Kurt
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyBalázs Tatár
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkJeremy Kendall
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes ramakesavan
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial추근 문
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Balázs Tatár
 
DRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEWDRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEWDrupalCamp Kyiv
 
Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Evgeny Nikitin
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1Jano Suchal
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascriptAlmog Baku
 
Анатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zАнатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zLEDC 2016
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128PrinceGuru MS
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptDarren Mothersele
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesDesarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesLuis Curo Salvatierra
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 

Similar to Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011 (20)

DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmd
 
Let's write secure Drupal code!
Let's write secure Drupal code!Let's write secure Drupal code!
Let's write secure Drupal code!
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
 
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, GermanyLet's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
Let's write secure Drupal code! - 13.09.2018 @ Drupal Europe, Darmstadt, Germany
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Backbone.js Simple Tutorial
Backbone.js Simple TutorialBackbone.js Simple Tutorial
Backbone.js Simple Tutorial
 
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018Let's write secure Drupal code! - DrupalCamp Oslo, 2018
Let's write secure Drupal code! - DrupalCamp Oslo, 2018
 
DRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEWDRUPAL 8 STORAGES OVERVIEW
DRUPAL 8 STORAGES OVERVIEW
 
Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascript
 
Анатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zАнатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to z
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesDesarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móviles
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 

More from camp_drupal_ua

Peter Lozovitsky.Money under your feet or why you have not already training i...
Peter Lozovitsky.Money under your feet or why you have not already training i...Peter Lozovitsky.Money under your feet or why you have not already training i...
Peter Lozovitsky.Money under your feet or why you have not already training i...camp_drupal_ua
 
Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011
Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011
Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011camp_drupal_ua
 
Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011
Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011
Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011camp_drupal_ua
 
Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...
Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...
Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...camp_drupal_ua
 
Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011
Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011
Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011camp_drupal_ua
 
Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011
Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011
Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011camp_drupal_ua
 
Artem Pankov.Eclipse.DrupalCamp Kyiv 2011
Artem Pankov.Eclipse.DrupalCamp Kyiv 2011Artem Pankov.Eclipse.DrupalCamp Kyiv 2011
Artem Pankov.Eclipse.DrupalCamp Kyiv 2011camp_drupal_ua
 
Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011
Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011
Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011camp_drupal_ua
 
Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...
Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...
Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...camp_drupal_ua
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011camp_drupal_ua
 
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
 
Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011
Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011
Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011camp_drupal_ua
 
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011camp_drupal_ua
 
Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011
Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011
Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011camp_drupal_ua
 
Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011
Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011
Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011camp_drupal_ua
 
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011camp_drupal_ua
 
Grigory naumovets.multilingual sites.drupal camp kyiv 2011
Grigory naumovets.multilingual sites.drupal camp kyiv 2011Grigory naumovets.multilingual sites.drupal camp kyiv 2011
Grigory naumovets.multilingual sites.drupal camp kyiv 2011camp_drupal_ua
 
Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011
Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011
Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011camp_drupal_ua
 
Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011
Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011
Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011camp_drupal_ua
 
Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011
Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011
Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011camp_drupal_ua
 

More from camp_drupal_ua (20)

Peter Lozovitsky.Money under your feet or why you have not already training i...
Peter Lozovitsky.Money under your feet or why you have not already training i...Peter Lozovitsky.Money under your feet or why you have not already training i...
Peter Lozovitsky.Money under your feet or why you have not already training i...
 
Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011
Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011
Alexandr Shvets.Trends in drupal.DrupalCamp Kyiv 2011
 
Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011
Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011
Dmitry Kostyuk.Cloud hosting for drupal.DrupalCamp Kyiv 2011
 
Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...
Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...
Vadim Mirgorod.Best practices for cross browser compatibility of drupal websi...
 
Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011
Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011
Sergey Korzh.CCK 3 presentation.DrupalCamp Kyiv 2011
 
Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011
Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011
Dennis Povshedny.Mediamosa intro.DrupalCamp Kyiv 2011
 
Artem Pankov.Eclipse.DrupalCamp Kyiv 2011
Artem Pankov.Eclipse.DrupalCamp Kyiv 2011Artem Pankov.Eclipse.DrupalCamp Kyiv 2011
Artem Pankov.Eclipse.DrupalCamp Kyiv 2011
 
Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011
Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011
Vasily Yaremchuk.Single page website.DrupalCamp Kiev 2011
 
Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...
Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...
Anton Paschenko.Geolocation with Apach Solr using search API.DrupalCamp Kyiv ...
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
 
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
 
Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011
Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011
Pavel Prischepa.node load without-restrictions.DrupalCamp Kiev 2011
 
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
Anna Fedoruk.Theworkflow.DrupalCamp Kyiv 2011
 
Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011
Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011
Viktor Levandovsky.Why drupal.DrupalCamp Kyiv 2011
 
Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011
Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011
Petrov Olexandr.Varnish and drupal.DrupalCamp Kyiv 2011
 
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
 
Grigory naumovets.multilingual sites.drupal camp kyiv 2011
Grigory naumovets.multilingual sites.drupal camp kyiv 2011Grigory naumovets.multilingual sites.drupal camp kyiv 2011
Grigory naumovets.multilingual sites.drupal camp kyiv 2011
 
Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011
Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011
Ramil Kinzyabulatov.Organization online store.DrupalCamp Kyiv 2011
 
Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011
Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011
Ilivanov Alexander.How to make best theme.DrupalCamp Kyiv 2011
 
Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011
Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011
Roman Chernov.Panels custom layouts.DrupalCampKyiv 2011
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Nickolay Shmalenuk.Render api eng.DrupalCamp Kyiv 2011

  • 1. Render API in Drupal7 Shmaleniuk Nikolay n.shmaleniuk@gmail.com
  • 4. Render API introduction Render API similar to the work of the Form API. 1. The system collects an array which contains all the necessary data – Array data converted to html and displayed
  • 5. Main hooks • hook_page_build add items to the page • hook_page_alter override the output of all page elements before output
  • 6.
  • 8.
  • 9.
  • 10. Render API theming • #theme - theme_function to be called • #arg_1, #arg_2 - arguments with prefix "#", necessary for the theme function
  • 11. The advantages of using • One general system of generating output data • All html on the page, can be easily overridden by using a one hook • Reusability code. Reusability the menu callbacks or blocks for the their tasks (eg AJAX replies) • Caching
  • 12. 3 types of element 1. Standerd element, key #type (hook_element_info()) 2. Text data, key #markup 3. Theme element, key #theme
  • 13. Example, node.tpl.php render(), show(), hide() <?php hide($content['comments']); hide($content['links']); print render($content); ?> <?php if (!empty($content['links'])): ?> <div class="links"><?php print render($content['links']); ?> </div> <?php endif; ?> <?php print render($content['comments']); ?>
  • 14. Example // Drupal 6. function my_module_show_same_items() { $items = array('item 1', 'item 2', 'item 3'); $out = theme('item_list', $items); return $out; } // Drupal 7. function my_module_show_some_items() { $items = array('item 1', 'item 2', 'item 3'); $build = array( 'items' => array('#theme' => 'item_list', '#items' => $items), ); return $build; }
  • 15. Example function theme_pager_link($variables) { $var_text = $variables['var']; $var_page_new = $variables['var_2']; ... } function my_module_show_some_text() { $item = array( 'items' => array( '#theme' => 'pager_link', '#var' => 'some text', '#var_2' => '...', ), ); return $item; }
  • 16. The array keys Render API • #access - TRUE or FALSE • #type - str • #printed - TRUE or FALSE • #cache - array() • #theme - str • #theme_wrappers - array() • #pre_render - array() • #post_render - array() • #attached - array() • #prefix, #suffix - str
  • 17. Sequence of actions drupal_render() 1. Checking #access и #printed 2. Checking the cache 3. Loading the default item (if #type) 4. Call #pre_render 5. Call #theme 6. Call #theme_wrappers 7. Call #post_render 8. Load attached recurses #attached (JS, CSS, etc.) 9. If #cache set, the write cache 10.return #prefix . $out . #suffix;
  • 18. Attached recurses, JS/CSS files $form['#attached']['css'] = array( drupal_get_path('module', 'ajax_example') . '/ajax_example.css', ); $form['#attached']['js'] = array( drupal_get_path('module', 'ajax_example') . '/ajax_example.js', );
  • 19. Attached recurses, JS settings $settings = array('id' => 'mymodule-element-1'); $form['#attached']['js'][] = array( 'data' => array('mymodule' => $settings), 'type' => 'setting', );
  • 20. Attached recurses, http header and library $form['#attached']['drupal_add_http_header'] = array( array('Content-Type', 'application/rss+xml; charset=utf-8'), ); $form['#attached']['library'][] = array('system', 'drupal.ajax');
  • 21. Caching $build = array( 'items' => array( '#theme' => 'item_list', '#items' => $items, '#cache' => array( 'keys' => array('example', 'cache'), 'bin' => 'cache', 'expire' => time() + $interval, 'granularity' => DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE, ), ), );
  • 22. Caching $items = module_load_item_list(); $build = array( 'items' => array( '#theme' => 'item_list', '#items' => $items, '#cache' => array( 'keys' => array('example', 'cache'), 'bin' => 'cache', 'expire' => time() + $interval, 'granularity' => DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE, ), ), );
  • 23. Caching $build = array( 'items' => array( '#theme' => 'item_list', '#pre_render' => array( 'module_load_item_list'), '#items' => array(), '#cache' => array( 'keys' => array('example', 'cache'), 'granularity' => DRUPAL_CACHE_PER_PAGE, ), ), ); function module_load_item_list(&$element) { $element['#items'] = module_load_item_list(); }
  • 24. • Render Arrays in Drupal http://drupal.org/node/930760 • Examples http://drupal.org/project/examples Shmaleniuk Nikolay n.shmaleniuk@gmail.com