Drupal 7 as a rad tool
Upcoming SlideShare
Loading in...5
×
 

Drupal 7 as a rad tool

on

  • 2,994 views

Forget Ruby on Rails, Drupal 7 is ready to kick your aps.

Forget Ruby on Rails, Drupal 7 is ready to kick your aps.

Statistics

Views

Total Views
2,994
Views on SlideShare
2,994
Embed Views
0

Actions

Likes
1
Downloads
41
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Drupal 7 as a rad tool Drupal 7 as a rad tool Presentation Transcript

  • 7 as a RAD Tool Im not kidding
  • Not a drag and drop app builderHook system not obvious Reminiscent of old word processor print driversBest suited to web apps Output need not HTML XML, RSS, servicesNew in 7 render elements universal - used to be in formRender elements are new to Drupal 7s theme layer. Theyve existed since Drupal 4.7 as part of the Form API, but theyve now been injected into the heart of the theme system. A Renderelement is a complex data structure passed as a single parameter to theme(), as one of its variables. Render elements are fundamentally nested arrays that can include:The data to be rendered Other render elements which are considered "children" of the element An array of structures such as CSS and JavaScript files, that should be attached to the pagewhen it is rendered A list of theme hooks that can be used to theme the data A list of callback functions to run on the element before and after it is themedClimbing the hook tree You can see a good implementation of this in viewsIn Drupal 7, there are 184 theme hooks that you could use in your own code. Many of those theme hooks are specific to a core modules usage, like theming an administration form, but itsstill useful to go through the entire list to find hooks you could reuse. To make it even easier, weve included a list of the most commonly reused theme hooks:Credo: Sacrifice the API, preserve data. Means that API chances between version can be apocalyptic.Data values in forms - move data in array - form_statePersistent data in dbTokens in coreLike several things moved into core, admin/interface remains in contrib - see field APIDrupal 7 introduces major changes to the way Drupal handles content. In earlier versions, nearly all content was considered a "node". By making content a standard object with a commonAPI, any module could add data to and manipulate that object to create complex data models and workflows.That worked extremely well, with the exception that Drupal had several other types of objects, such as users or comments, that were not really "content" per se but could still have benefitedfrom the same rich API. For Drupal 7, therefore, most of those separate object types were merged into a single super-system known as "entities". Nodes, users, comments, and severalother types of data objects are now particular instances of the generic Entity data object concept. That allows all types of data to have the same, or at least very similar, API and workflow,avoiding duplicate code and reducing the number of moving parts developers need to keep track of. Most importantly, it allows us to attach Fields, discrete structured pieces of information,to any type of entity rather than just to nodes.Bundles - entity subtypesSchema API
  • What is Drupal?• OOTB blog/website/CMS• A set of APIs that let you turn it into almost anything
  • What is Drupal?• OOTB blog/website/CMS • Okay, it’s still harder to get going than Wordpress, but it is much improved in that regard in Drupal 7 • We don’t care• A set of APIs that let you turn it into almost anything • This is the interesting part
  • Some Assumptions• You have heard of Drupal• You know that it is a popular CMS in the library community• You might know that it is easy to extend• You might have heard some of the reasons, like the hook system
  • We’re talkingframework here.
  • 7• Why so long?• Better alignment of contributed and core funcionality• Stuff we have been waiting for since Drupal 5 and Drupal 4.7• #D7CX pledge: • My module will be ready on the day Drupal 7 is released
  • The Drupal CredoSac!fice " API, preserve " data • Means that user data is gold. Developer effort is expendable. • API changes between versions can be apocalyptic.
  • (Short) Tale of Two Drupals• Modules• Theme • Theme hooks • Templates
  • Hook• Reminiscent of ancient word processor print driver system • Intercepted processes to build print stream • Matched two APIs • What the program wanted to send • What the printer expected to see • Economics - word processor companies wanted others to do their work for them• Flash forward • Open source software • A very simple system that allows developers to insert or modify functionality almost anywhere. Without talking to each other.
  • Core Hooks in Drupal 6custom_url_rewrite_inboundphp hook_hook_info hook_searchcustom_url_rewrite_outboundphp hook_init See also, hook_boot. hook_search_preprocesshook_access hook_insert hook_system_info_alterinfo fileshook_actions_delete hook_install hook_taxonomyhook_action_info hook_link hook_term_pathhook_action_info_alter hook_link_alter hook_themehook_block hook_load hook_theme_registry_alterhook_boot See also, hook_init. 78 hook_locale hook_translated_menu_link_alterhook_comment hook_mail hook_translation_link_alterhook_cron hook_mail_alterhook_menu hook_uninstallhook_db_rewrite_sql hook_menu_alter hook_updatehook_delete hook_menu_link_alter hook_update_indexhook_disable hook_nodeapi hook_update_last_removedhook_elements hook_node_access_records hook_update_Nhook_enable hook_node_grants hook_update_projects_alterhook_exit hook_node_info hook_update_status_alterhook_file_download hook_node_operations hook_userhook_filter hook_node_type hook_user_operationshook_filter_tips hook_openid hook_validatehook_flush_caches hook_perm hook_viewhook_footer hook_ping hook_watchdoghook_form hook_prepare module_hookhook_forms hook_profile_alter module_implementshook_form_alter hook_requirements module_invokehook_form_FORM_ID_alter hook_schema module_invoke_allhook_help hook_schema_alter page_cache_fastpath
  • Core Hooks in Drupal hook_actions_delete hook_action_info hook_action_info_alter hook_admin_paths hook_admin_paths_alter 7 hook_entity_delete hook_entity_info hook_entity_info_alter hook_entity_insert hook_entity_load hook_js_alter hook_language_fallback_candidates_alter hook_language_init hook_language_negotiation_info hook_language_negotiation_info_alter hook_node_update_index hook_node_validate hook_node_view hook_node_view_alter hook_openid hook_aggregator_fetch hook_entity_prepare_view hook_language_switch_links_alter hook_openid_discovery_method_info hook_aggregator_fetch_info hook_entity_presave hook_language_types_info hook_openid_discovery_method_info_alter hook_aggregator_parse hook_entity_query_alter hook_language_types_info_alter hook_openid_normalization_method_info hook_aggregator_parse_info hook_entity_update hook_library hook_openid_normalization_method_info_alter hook_aggregator_process hook_entity_view hook_library_alter hook_openid_response hook_aggregator_process_info 266 hook_entity_view_alter hook_load hook_overlay_child_initialize hook_aggregator_remove hook_exit hook_locale hook_overlay_parent_initialize hook_ajax_render_alter hook_filetransfer_info hook_mail hook_page_alter hook_archiver_info hook_filetransfer_info_alter hook_mail_alter hook_page_build hook_archiver_info_alter hook_file_copy hook_menu hook_page_delivery_callback_alter hook_batch_alter hook_file_delete hook_menu_alter hook_path_delete hook_block_configure hook_file_download hook_menu_breadcrumb_alter hook_path_insert hook_block_info hook_file_insert hook_menu_contextual_links_alter hook_path_updatehook_block_info_alter hook_file_load hook_menu_delete hook_permissionhook_block_list_alter hook_file_mimetype_mapping_alter hook_menu_get_item_alter hook_preparehook_block_save hook_file_move hook_menu_insert hook_query_alterhook_block_view hook_file_presave hook_menu_link_alter hook_query_TAG_alterhook_block_view_alter hook_file_update hook_menu_link_delete hook_rankinghook_block_view_MODULE_DELTA_alter hook_file_url_alter hook_menu_link_insert hook_rdf_mappinghook_boot See also, hook_init. hook_file_validate hook_menu_link_update hook_rdf_namespaceshook_comment_delete hook_filter_format_disable hook_menu_local_tasks_alter hook_registry_files_alterhook_comment_insert hook_filter_format_insert hook_menu_site_status_alter hook_requirementshook_comment_load hook_filter_format_update hook_menu_update hook_schemahook_comment_presave hook_filter_info hook_modules_disabled hook_schema_alterhook_comment_publish hook_filter_info_alter hook_modules_enabled hook_search_accesshook_comment_unpublish hook_flush_caches hook_modules_installed hook_search_adminhook_comment_update hook_form hook_modules_uninstalled hook_search_executehook_comment_view hook_forms hook_module_implements_alter hook_search_infohook_comment_view_alter hook_form_alter hook_multilingual_settings_changed hook_search_pagehook_contextual_links_view_alter hook_form_BASE_FORM_ID_alter hook_node_access hook_search_preprocesshook_countries_alter hook_form_FORM_ID_alter hook_node_access_records hook_search_resethook_cron hook_help hook_node_access_records_alter hook_search_statushook_cron_queue_info hook_hook_info hook_node_delete hook_shortcut_default_sethook_cron_queue_info_alter hook_hook_info_alter hook_node_grants hook_simpletest_alterhook_css_alter hook_html_head_alter hook_node_grants_alter hook_stream_wrappershook_custom_theme hook_image_default_styles hook_node_info hook_stream_wrappers_alterhook_dashboard_regions hook_image_effect_info hook_node_insert hook_system_info_alterinfo fileshook_dashboard_regions_alter hook_image_effect_info_alter hook_node_load hook_system_themes_page_alterhook_date_formats hook_image_styles_alter hook_node_operations hhook_date_formats_alter hook_image_style_delete hook_node_prepare ook_taxonomy_term_deletehook_date_format_types hook_image_style_flush hook_node_presave hook_taxonomy_term_inserthook_date_format_types_alter hook_image_style_save hook_node_revision_delete hook_taxonomy_term_loadhook_delete hook_image_toolkits hook_node_search_result hook_taxonomy_term_presavehook_disable hook_init See also, hook_boot. hook_node_submit hook_taxonomy_term_updatehook_drupal_goto_alter hook_insert hook_node_type_delete hook_taxonomy_term_view_alterhook_element_info hook_install hook_node_type_insert hook_taxonomy_vocabulary_deletehook_element_info_alter hook_install_tasks hook_node_type_update hook_taxonomy_vocabulary_inserthook_enable hook_install_tasks_alter hook_node_update hook_taxonomy_vocabulary_load
  • What’s in the BoxFiles that say stuff:CHANGELOG.txtCOPYRIGHT.txtINSTALL.mysql.txtINSTALL.pgsql.txtINSTALL.sqlite.txtINSTALL.txtLICENSE.txtMAINTAINERS.txtREADME.txtUPGRADE.txt
  • What’s in the BoxFiles that do stuff:authorize.phpcron.phpindex.phpinstall.phprobots.txtupdate.phpweb.configxmlrpc.php
  • What’s in the BoxDirectories:includesmiscprofilesscriptsmodulesthemessites all modules themes libraries default
  • Modules• Core module• Contrib modules• Learn to love associative arrays. Passing data in strings is dead(ish)• By using core hooks, modules achieve instant interoperabity
  • help.info; $Id: help.info,v 1.9 2010/12/20 19:59:42 webchick Exp $name = Helpdescription = Manages the display of online help.package = Coreversion = VERSIONcore = 7.xfiles[] = help.test; Information added by drupal.org packaging script on 2011-01-05version = "7.0"project = "drupal"datestamp = "1294208756"
  • help.module -1<?php// $Id: help.module,v 1.99 2010/10/04 14:54:10 webchick Exp $/** * @file * Manages displaying online help. */}
  • help.module -2/** * Implements hook_menu(). */function help_menu() { $items[admin/help] = array( title => Help, description => Reference for usage, configuration, and modules., page callback => help_main, access arguments => array(access administration pages), weight => 9, file => help.admin.inc, ); foreach (module_implements(help, TRUE) as $module) { $items[admin/help/ . $module] = array( title => $module, page callback => help_page, page arguments => array(2), access arguments => array(access administration pages), type => MENU_VISIBLE_IN_BREADCRUMB, file => help.admin.inc, ); } return $items;}
  • help.module -3/** * Implements hook_help(). */function help_help($path, $arg) { switch ($path) { case admin/help: $output = <p> . t(Follow these steps to set up and start using your website:) . </p>; $output .= <ol>; $output .= <li> . t(<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where youcan <a href="@config">customize and configure</a> all aspects of your website., array(@admin => url(admin), @config => url(admin/config))) .</li>; $output .= </ol>; $output .= <p> . t(For more information, refer to the specific topics listed in the next section or to the <a href="@handbook">online Drupalhandbooks</a>. You may also post at the <a href="@forum">Drupal forum</a> or view the wide range of <a href="@support">other supportoptions</a> available., array(@help => url(admin/help), @handbook => http://drupal.org/handbooks, @forum => http://drupal.org/forum,@support => http://drupal.org/support)) . </p>; ---snip--- return $output; case admin/help#help: $output = ; $output .= <h3> . t(About) . </h3>; ---snip--- $output .= <h3> . t(Uses) . </h3>; $output .= <dl>; $output .= <dt> . t(Providing a help reference) . </dt>; ---snip--- $output .= <dd> . t(The Help module displays context-sensitive advice and explanations on various pages.) . </dd>; $output .= </dl>; return $output; }}
  • help.test<?php// $Id: help.test,v 1.22 2010/11/27 20:25:44 dries Exp $class HelpTestCase extends DrupalWebTestCase { protected $big_user; protected $any_user; public static function getInfo() { return array( name => Help functionality, description => Verify help display and user access to help based on permissions., group => Help, ); } /** * Enable modules and create users with specific permissions. */ function setUp() { parent::setUp(blog, poll); $this->getModuleList(); // Create users. $this->big_user = $this->drupalCreateUser(array(access administration pages, view the administration theme,administer permissions)); $this->any_user = $this->drupalCreateUser(array()); }}
  • Drupal APIs. Yum.• core modules call core hooks• Drupal 8 will be even more reliant on its own APIs
  • New in Drupal 7• Besides 190 new hooks• More granular control of processing order • 12 levels of preprocess function minimize can’t get there from here issues• SimpleTest framework in core• Generally more consistent
  • So, What’s it Good For• CMS• WEB based applications• Front ends to dedicated apps • Islandora• RDF• Multi-output (XML, etc.)• Data apps• Anything
  • That’s All• api.drupal.org• Cary Gordon The Cherry Hill Company Los Angeles, CA 310-397-2999 cgordon@chillco.com highermath (Drupal, irc, twitter, etc)• BoF this afternoon