Converting XMLRPC using modules
The first Drupal versions to use the new library are 4.5.5, 4.6.3 and 4.7. If you have a custom written Drupal module for an older version, then the following applies. return array 'foaf.getUrl' gt array 'function' gt 'foaf_get_url' gt return array 'foaf.getUrl' gt 'foaf_get_url' gt Now let's see the handler function itself. It's parameters are regular PHP variables now, there is nothing to process. So now you can write things like function username, password instead of doing parameter...
WinMerge
While these programs do a nice job in showing file differences visually, side by side, non of them as i can tell allows to actually save the difference in unified format most allow to save a standard diff, though - update TortoiseCVS lets you save patches. It does unified format by default. See its Make Patch option. Note that this 'Make Patch' option can make recursive patches when applied to directories. You cannot specify the -u in the External diff preferences eg diff -u as this will...
Theme engine integration
Your site's theme may have special content and features that do not exist in Drupal themes. This section will explain how you can use your own themes using Drupal's theme engines. If all you need to achieve a common look and feel, you do not need to modify a theme engine, you can simply create a new template based on your site's design elements. Drupal currently has the following theme engines Xtemplate, PHPTemplate, Smarty and Plain PHP. You can read an in-depth explanation of these template...
Text output
Drupal's text output was audited and several escaping bugs were found. For more info, see the check_plain patch. You need to pay attention that all user-submitted plain-text in your module is escaped using check_plain when you output it into HTML. No escaping should be done on data that is going into the database only escape when outputting to HTML. Check_plain replaces drupal_specialchars and check_form , so if you are using any of those two, you should use check_plain instead. You should also...
Taxonomy API change
In order to provide more meaningful messages to the user, now you can provide your own messages when using the taxonomy APIs to create or modify terms and vocabularies. The taxonomy_save_vocabulary and taxonomy_save_term functions now return a status message which can be either SAVED_NEW, SAVED_UPDATED or SAVED_DELETED. The function will return NULL when there was an error. Also note that you must call these with an edit array parameter which will be modified, and will include the 'vid' key....
Flowcharts
Forms API Quickstart Guide links to drupaldocs.org Forms API Reference links to drupaldocs.org Also see the Form Updater module, which can help you get a head start in converting your modules. Before embarking on the journey to update a module to the new forms API, it is helpful to understand more about the conversion process in general, and the benefits it provides. First, it should be noted that for many module maintainers, converting their module to use the new forms API will be the most...
hookform Ppw
hook_form allows for a form for adding, editing and deleting nodes of the type for the curious this 4.7 implementation of hook_form is substantially different from 4.6 form 'title' array ' type' gt 'textfield', ' title' gt t 'Title' , ' required' gt TRUE, ' default_value' gt node- gt title form 'body' array ' type' gt 'textarea', ' title' gt t 'Body' , ' default_value' gt node- gt body, ' rows' gt 20, ' required' gt TRUE form 'format' filter_form node- gt format form 'log' array ' type' gt...
hookform Chb
Before each hook is implemented you should you will see a php comment Implementation of hook_help . Implementation of hook_node_info . After the comment, the hook function is called, but instead of the word hook the word story is used as this module was originally for story nodes. In the function calls change story to your technical-name, in our example release for hook_help We will be changing all 7 in the following steps, plus a few more things Here are the changes, moving down the file,...
Plurals Solution Sao
The plural forms to use in PO edit under catalog-settings where you see nplural INTEGER plural EXPRESSION Only one form Some languages only require one single form. There is no distinction between the singular and plural form. An appropriate header entry would look like this Languages with this property include Two forms, singular used for one only This is the form used in most existing programs since it is what English is using. A header entry would look like this Plural-Forms nplurals 2...
node definition changes
In 4.6, you had hook_node_name and hook_node_types. Now you must implement hook_node_info if you want to create a module which defines node type s . The implementation of the hook_node_info needs to return array type1 gt array 'name' gt name1, 'base' gt base1 , type2 gt array 'name' gt name2, 'base' gt base2 where type is the node type, name is the human readable name of the type and base is For example, the story module's node_info hook looks like this return array 'story' gt array 'name' gt t...
Drupals Javascript tools
Drupal's javascript toolkit has three basic components The javascript file drupal.js contains methods for implementing Javascript solutions, including AJAX see below . Specific Drupal functions in PHP help Javascript developers. These include drupal_add_j s , used for adding a js file to a page drupal_call_j s , used to generate a javascript call and drupal_to_js , used to translate data from Drupal PHP to Javascript objects. As well as the generic tools in drupal.js and the PHP Javascript...
Write EALL compliant code Introductionary notice
This document is a very recent addition to the coding guidelines, and is still subject to discussion among developers. Do NOT post comments on this page yet. One issue will be created for each point introduced here. Those issues will be used for discussion and patch submission. I'll keep updating this page as the discussion progresses. When a consensus has been reached on each point, this introduction will be deleted. Eventually, when everything has been patched up, I'll delete the mention...
hookaccess 1
hook_access checks your permissions against a user and what the permission allows these need to aggree with hook_perm above hook_access original code from story.module function story_access op, node global user return user_access 'create stories' if op 'update' op 'delete' if user_access 'edit own stories' amp amp user- gt uid node- gt uid return TRUE here we need our technical name and plural as indicated function technical_access op, node global user return user_access 'create plural' if op...
How do you use the validation arguments
valid gt 'integer' , validation arguments gt array 1, 13 This would map to valid_integer form 'element' , 1, 13 where 1, 13 could be min max allowed values. If you have multiple validation functions, use valid gt array 'integer', 'uid' , validation arguments array array 1, 13 , array 'anonymous' which would map to valid_integer form 'element' , 1, 13 and valid_uid form 'element' , 'anonymous' where the second parameter could be role, for instance, so you could see if it's a valid uid in a...
Session handler issues
Managing your session issues will greatly depend on how your application handles sessions, But the Drupal side of things is straight forward. The session.inc file is included in the bootstrap.inc file. If you decide to exclusively use your application's session handler, you can simply comment out that line from bootstrap.inc. Or you may decide to allow both to do different parts, where your application session handles authentication, and let Drupal sessions handle the rest of Drupal functions....
Database table prefix
On 2003 Jul 10, Dries committed Slavica's table prefix patch which allows for a configurable prefix to each drupal mysql table to easily share one database for multiply applications on server with only one database allowed. This patch requires all table names in SQL-queries to be enclosed in curly brackets , eg. - db_query DELETE FROM book WHERE nid d, node- gt nid db_query DELETE FROM book WHERE nid d, node- gt nid so that the table prefix can be dynamically prepended to the table name. See...
Prebuilt autocomplete functions
Two autocomplete functions ship with the Drupal core. Each is referenced by an autocomplete_path--the uri to which autocomplete requests are sent. Use this function to load matching user names. Autocomplete path user autocomplete. Use this function to load matching taxonomy terms from a given vocabulary. Autocomplete path taxonomy automplete. If one of these matches your needs, then all you need to do is include the special autocomplete_path selector in a form field. Here's an example for user...
hookonload replaced by addLoadEvent
If you need to add Javascript onLoad events from your modules you now need to use the Drupal custom Javascript function addLoadEvent func . This was done to allow for new Javacript functions in the core. return array 'my_javascript_function ' TO BE USED INSIDE YOUR FUNCTION THAT NEEDS TO LOAD A JAVASCRIPT FUNCTION
Modifying checkboxes to display in multiple columns
This tip will show you how to modify the checkboxes element type so that checkboxes display in multiple columns instead of one single column. This is particulary useful for modules that would have users select from a very long list of choices. This tip will help you present the checkboxes in a more compact form, making your site more user friendly. Disclaimer This document shares how I solved this particular problem and doesn't claim to be anything more. There may be other ways of accomplishing...
Tutorial Creating new Javascript widgets
If you want to implement functionality not already available, you'll create a new Javascript file and then write PHP calls that add to the page what's needed for the Javascript to work. So, to come up with a simple if fairly useless example, say we want to write a module that allows users to click on specific words and get a message with further information. Here's how we might do it. Use CSS class selectors to identify the elements to add the Javascript to. You might be familiar with the...