Two New JavaScript Features in Drupal 6. AHAH and Drag and Drop (JavaScript so you don t have to)

Similar documents
Using your Drupal Website Book 1 - Drupal Basics

Context-sensitive Help Guide

Global Preview v.6.0 for Microsoft Dynamics CRM On-premise 2013 and 2015

Data Management Applications with Drupal as Your Framework

1. To start Installation: To install the reporting tool, copy the entire contents of the zip file to a directory of your choice. Run the exe.

BT CONTENT SHOWCASE. JOOMLA EXTENSION User guide Version 2.1. Copyright 2013 Bowthemes Inc.

Magic Liquidizer Documentation

Drupal Module Development

Absolute Beginner s Guide to Drupal

Spotfire v6 New Features. TIBCO Spotfire Delta Training Jumpstart

Typography and Drupal. What does Drupal provide? Ashok Modi DDCLA 2011

Dreamweaver Tutorial - Dreamweaver Interface

UNIVERSITY OF CALGARY Information Technologies WEBFORMS DRUPAL 7 WEB CONTENT MANAGEMENT

Admin Guide Product version: Product date: November, Technical Administration Guide. General

SellerDeck 2013 Reviewer's Guide

Shipbeat Magento Module. Installation and user guide

Drupal Performance Tuning

SAHARA DIGITAL8 RESPONSIVE MAGENTO THEME

BT MAGAZINE. JOOMLA 3.x TEMPLATE. Total User Guide Version 1.0. Copyright 2013 Bowthemes.com

Drupal 7 Fields/CCK Beginner's Guide

ADP Workforce Now V3.0

v7.1 SP2 What s New Guide

BusinessObjects Enterprise InfoView User's Guide

Rochester Institute of Technology. Finance and Administration. Drupal 7 Training Documentation

DIPLOMA IN WEBDEVELOPMENT

MASTER DRUPAL 7 MODULE DEVELOPMENT

DocuSign Signing Resource File Information

QuickCRM Mobile. Mobile Access to SugarCRM. User Manual. Version: 2.6

Monthly Payroll to Finance Reconciliation Report: Access and Instructions

Vector HelpDesk - Administrator s Guide

This manual cannot be redistributed without permission from joomla-monster.com

LEARNING DRUPAL. Instructor : Joshua Owusu-Ansah Company : e4solutions Com. Ltd.

CiviCRM for Drupal Developers

Magento Theme EM0006 for Computer store

Google Sites: Creating, editing, and sharing a site

DROPFILES SUPPORT. Main advantages:

A database is a collection of data organised in a manner that allows access, retrieval, and use of that data.

MicroStrategy Quick Guide: Creating Prompts ITU Data Mart Support Group, Reporting Services

How To Write A

Page Editor Recommended Practices for Developers

Certified PHP/MySQL Web Developer Course

Developers Guide version 1.1

USING MYWEBSQL FIGURE 1: FIRST AUTHENTICATION LAYER (ENTER YOUR REGULAR SIMMONS USERNAME AND PASSWORD)

Trial version of GADD Dashboards Builder

BT BACKGROUND SLIDESHOW JOOMLA EXTENSION User guide Version 2.0

Content Management Software Drupal : Open Source Software to create library website

Webforms on a Drupal 7 Website 3/20/15

Develop a Native App (ios and Android) for a Drupal Website without Learning Objective-C or Java. Drupaldelphia 2014 By Joe Roberts

FWG Management System Manual

Business Objects Reports Influenza Vaccinations User Guide

TRIM: Web Tool. Web Address The TRIM web tool can be accessed at:

CREATING AND EDITING CONTENT AND BLOG POSTS WITH THE DRUPAL CKEDITOR

GETTING STARTED WITH DRUPAL. by Stephen Cross

Bitrix Site Manager 4.1. User Guide

CLASSROOM WEB DESIGNING COURSE

Wildix Web API. Quick Guide

Building Responsive Websites with the Bootstrap 3 Framework

Web Development using PHP (WD_PHP) Duration 1.5 months

UW- Madison Department of Chemistry Intro to Drupal for Chemistry Site Editors

Oracle Business Intelligence (OBI) User s Guide October 2011

Introduction to Drupal

MAGENTO THEME SHOE STORE

Site Audit ( /site_audit) Generated on Fri, 22 Aug :14:

Introduction to Module Development

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

HOW TO CREATE AN HTML5 JEOPARDY- STYLE GAME IN CAPTIVATE

Drupal 8 The site builder's release

Web Development 1 A4 Project Description Web Architecture

Table of Contents. Welcome Login Password Assistance Self Registration Secure Mail Compose Drafts...

Magento module Documentation

CMSC434 TUTORIAL #3 HTML CSS JavaScript Jquery Ajax + Google AppEngine Mobile WebApp HTML5

WordPress websites themes and configuration user s guide v. 1.6

BT MEDIA JOOMLA COMPONENT

Avaya Network Configuration Manager User Guide

BUILDING MULTILINGUAL WEBSITES WITH DRUPAL 7

Bazaarvoice for Magento Extension Implementation Guide v6.3.4

Configuring the JEvents Component

CRM Add-On (For WPL) Realtyna Inc.

Bubble Code Review for Magento

Sage Accpac ERP 5.6A. CRM Analytics for SageCRM I User Guide

Content Management Systems: Drupal Vs Jahia

Installing and Using Joomla Template Created with Artisteer

Example for Using the PrestaShop Web Service : CRUD

Designing and Implementing Forms 34

MICROSOFT ACCESS STEP BY STEP GUIDE

QUICK START FOR COURSES: USING BASIC COURSE SITE FEATURES

Drupal 8 rocks! (but our CSS & HTML sucks.) Drupal 8 ( CSS HTML )

MHC Drupal User Manual: Webforms

Oracle Sales Offline. 1 Introduction. User Guide

Sophos Mobile Control Startup guide. Product version: 3

Chapter 5 Configuring the Remote Access Web Portal

Transcription:

Two New JavaScript Features in Drupal 6 AHAH and Drag and Drop (JavaScript so you don t have to)

Dragon Drop +

Drag and Drop + An easy way of arranging content with JavaScript (jquery)

Drag and Drop Compatible with every major browser: Allows the sorting of elements within a table Works to eliminate the word weight from Drupal Implemented in the theme layer Easy to implement in just a few lines of code IE (6/7), Firefox 1.5+, Safari 2+, Opera 9, Konqueror

Drag and Drop HTML HTML is identical in JavaScript and non-javascript versions Tabledrag.js makes all changes to the page Completely degradable

Drag and Drop HTML

Kick-ass Demo Block, Menu

When you want to D&D 1. Create a form for organizing the elements using weight fields. 2. Theme your form into a table. 3. Put weights in an individual column. 4. Add special classes. 5. Call drupal_add_tabledrag() from your theme function.

Example: Filter Order Filter Module already had weight fields in a table in Drupal 5. 4. Add special classes. 5. Call drupal_add_tabledrag().

Special Classes and IDs All Drag and Drop tables must have: 1. An ID attribute on the table. 2. A draggable class on draggable rows. 3. A group class on fields in the same column In addition, tables with parents can use: 3. div.indentation to set initial indentation. 4. A tabledrag-root class on rows that cannot be indented. 5. A tabledrag-leaf class on rows that cannot have children.

drupal_add_tabledrag() The do-it-all PHP function. drupal_add_tabledrag( $table_id, // The ID of the table. $action, // match or order. $relationship, // parent or sibling. $group, // The weight field class. $subgroup = NULL, // Used on the blocks page. $source = NULL, // Parent group class. $hidden = TRUE, // Hide the weight column? $limit = 0 // Max parent depth. )

Filter D&D Patch foreach (element_children($form['names']) as $id) { // Don't take form control structures. if (is_array($form['names'][$id])) { - $rows[] = array(drupal_render($form['names'][$id]), drupal_render($form['weights'][$id])); + $form['weights'][$id]['#attributes']['class'] = 'filter-order-weight'; + $rows[] = array( + 'data' => array(drupal_render($form['names'][$id]), drupal_render($form['weights'][$id])), + 'class' => 'draggable', + ); } } - $output = theme('table', $header, $rows); + $output = theme('table', $header, $rows, array('id' => 'filter-order')); $output.= drupal_render($form); + drupal_add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, FALSE); + return $output; }

Simple Example: Filter Order

Tree Structures Add two tabledrag instances: Weight ordering Parent relationship

Tree Structures drupal_add_tabledrag( 'menu-overview', 'order', 'sibling', 'menu-weight' ); drupal_add_tabledrag( 'menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, // $table_id // $action // $relationship // $group // $table_id // $action // $relationship // $group // $subgroup // $source // $hidden MENU_MAX_DEPTH - 1 // $limit );

Where can I get it? Drupal Core Block Arrangement Menu Structure Taxonomy Terms Upload Attachments Book Outlines Profile Fields Filter Order Contrib CCK Fields Webform Fields Views(?)

AHAH Framework Allows dynamically updating forms without writing any custom JavaScript Can enhance existing forms with useful information from the server Implemented mostly in FormsAPI #ahah property (some theming needed for special cases)

Sweet, sweet demo Upload, CCK

Basic FormsAPI Field $form[ element ] = array( #type => textfield, #title => t( User name ), ); Forms are structured arrays Pound sign (#) means a property of that field

AHAH Enabled Field $form[ element ] = array( #type => textfield, #title => t( User name ), #ahah => array( path => mymodule/check_username, wrapper => valid_username, ), ); Path and wrapper are required #ahah properties.

AHAH Enabled Field $form[ element ] = array( #type => textfield, #title => t( User name ), #ahah => array( path => mymodule/check_username, wrapper => valid_username, ), #suffix => <div id= valid_username ></div>, );

AHAH Properties #ahah => array( path => mymodule/check_username, wrapper => valid_username, event => change, method => replace, progress => array( type => throbber ); ),

Extra AHAH options #ahah[ event ] has a reasonable default for form elements so you usually won t need to set it. #ahah[ progress ] Options array( type => throbber ) array( type => throbber, message =>... ); array( type => bar ) array( type => bar, message =>... ); array( type => bar, message =>..., path => sopme/path );

A Functional Example function regval_form_alter(&$form, $form_state, $form_id) { drupal_add_css(drupal_get_path('module', 'regval'). '/regval.css'); if ($form_id == 'user_register') { $form['name']['#ahah'] = array( 'path' => 'regval/name', 'wrapper' => 'regval-name-wrapper', 'progress' => 'none', 'event' => 'change', ); $form['name']['#suffix'] = '<div id="regval-name-wrapper"></div>'; } }

A Functional Example function regval_menu() { $items['regval/name'] = array( 'page callback' => 'regval_check_name', 'access callback' => 'regval_access_callback', 'type' => MENU_CALLBACK, ); }

A Functional Example function regval_check_name() { $name = $_POST['name']; if ($name!= '' &&!is_null($name)) { $exists = db_result(db_query("select uid FROM {users} WHERE name = '%s' AND uid!= %d", $name, $user->uid)); if ($exists) { $output = theme('image', 'misc/watchdog-error.png', t('error')).' '. t('username already exists.'); } else { $output = theme('image', 'misc/watchdog-ok.png', t('ok')).' '. t("username is available."); } print drupal_json(array('result' => TRUE, 'data' => $output)); } else { print ''; } }

Wee! demo Regval

Updating a Form Such as: A more button to add fields Drill-down structure Select list form changes Take into account FormsAPI security

Updating a Form 1. Retrieve form cache from database 2. Add additional fields to the database version of the form 3. Save the new form back to the database 4. Render the new part of the form and return it back to the original page

Updating a Form function poll_choice_js() { $delta = count($_post['choice']);... $form = form_get_cache($form_build_id, $form_state); $form['choice_wrapper']['choice'][$delta] = _poll_choice_form($delta); form_set_cache($form_build_id, $form, $form_state);... } drupal_json(array('status' => TRUE, 'data' => $output)); Form is updated on AHAH requests to maintain form security

Goals for the Future Remove path #ahah property and replace with callback Easily render small pieces of a form for AHAH form updates

Questions

D&D and AHAH Developers and Testers fajerstarter Stefan Nagtegaal scor catch nedjo eaton pwolanin chx Wim Leers webchick bdragon beginner Gábor Hojtsy Dries Many others. Thanks!