Wim Leers

CDN integration: mixing static file servers and CDNs

  1. function driverpacksnet_map_country_to_server($country_code) {
  2.   $countries_for_driverpacks_server = continents_api_get_countries('EU') + array('RU');
  3.   if (in_array($country_code, $countries_for_dr

Use pathauto to create an alias for url of a custom node tab

  1. /**
  2.  * REMARK: make sure your nodeapi implementation is called
  3.  * AFTER pathauto's, to ensure that you'll be using the latest
  4.  * alias information. pathauto has weight 1, so your module

_pathauto_build_alias_string() … or something like that?

  1.   // Replace the placeholders with the values provided by the module,
  2.   // and optionally lower-case the result
  3.   $alias = str_replace($placeholders['tokens'], $placeholders['values'], $pattern);

Initial code for new HS implementation: hs_smallhierarchy (or has somebody got a better name?)

  1. /**
  2.  * Automatically transform a given hierarchy with this format:
  3.  * array(
  4.  *   'win' => array(
  5.  *     'label' => 'Windows',
  6.  *     'children' => array(

AHAH in core: edge case

  1.   // If the form is being rebuilt due to something else than a pressed button,
  2.   // e.g. a select that was changed, then $_POST['op'] will be empty. As a

Code

  1. function ahah_helper_render($form_item_to_render = FALSE) {
  2.   $form_state = array('storage' => NULL, 'submitted' => FALSE);
  3.   $form_build_id = $_POST['form_build_id'];

Code

  1. /**
  2.  * Helper function to reconstruct the lineages given a set of selected items
  3.  * and the fact that the "save lineage" setting is enabled.
  4.  *

The Most Monstrous Function Ever

  1. /**
  2.  * Hierarchical select form element type #process callback.
  3.  */
  4. function hierarchical_select_process($element) {
  5.   static $hsid;
  6.  
  7.   if (!isset($hsid)) {
  8.     $hsid = 0;
  9.   }
  10.   else {

Code

  1. First of all - the form you see on screen and the $form array stored in the cache should always be the same.

IE sucks

  1. <div class="hierarchical-select-wrapper">
  2.   <div class="hierarchical-select">
  3.     <div class="wrapper">
  4.       <select><option value="bleh">bleh</option></select>
  5.       <div class="grippie" />

With inline comments this time!

  1. /**
  2.  * Definition of our hierarchy.
  3.  */
  4. function hs_tutorial_hierarchy() {
  5.   static $internal_hierarchy;
  6.  
  7.   // The user-visible hierarchy. Only defines labels. Has 3 levels.

Code

  1. /**
  2.  * Definition of our hierarchy.
  3.  */
  4. function hs_tutorial_hierarchy() {
  5.   static $internal_hierarchy;
  6.  
  7.   // The user-visible hierarchy. Only defines labels. Has 3 levels.

jQuery UI resizables

  1.   $('#hierarchical-select-' + hsid + '-wrapper .hierarchical-select')
  2.   // Make the selects of the hierarchical select resizable.
  3.   .find('select').each(function() {

Menu tasks

  1. // I want local tasks to appear… but it doesn't seem to be working very reliably!
  2.  
  3. // This works.
  4.   $items['admin/subscriptions'] = array(
  5.     'title'            => 'Mollom subscriptions',

Schema API weirdness

  1.       'customer' => array(
  2.         'type'        => 'int',
  3.         'size'        => 'tiny',
  4.         'unsigned'    => TRUE,
  5.         'not null'    => TRUE,
  6.         'default'     => 127,

Code

  1. <?php
  2.  
  3. // In the form definition:
  4.       $default = $form_state['storage']['billing_info'];
  5.  
  6.       $form['visible']['step2']['billing_info']['new']['usage'] = array(

Code

  1. <?php
  2. function poll_choice_js() {
  3.   $delta = count($_POST['choice']);
  4.  
  5.   // Build our new form element.
  6.   $form_element = _poll_choice_form($delta);

Adding submit handlers in D6

  1. /**
  2.  * Implementation of hook_form_alter().
  3.  */
  4. function hs_taxonomy_form_alter(&$form, &$form_state, $form_id) {
  5.   // Add per-vocabulary settings for Hierarchical Select.

Code

  1. /**
  2.  * Render callback.
  3.  */
  4. function theme_panels_tabs_style_render_panel($display, $owner_id, $panes, $settings) {
  5.   $output = '';

Panels caching drupal_add_js somehow… WTF?

  1. This is part of a dump of $javascript in drupal_get_js() in common.inc. See #3 and #4.
  2.  
  3.     [setting] => Array
  4.         (
  5.             [0] => Array
  6.                 (
Syndicate content