If you call functions drupal_add_js() or drupal_add_css() in a hook_form_alter() of a custom module, it may happen that if the form is not validated it won't load Javascrpt and CSS.
You can fix this problem by adding the #after_build to your form, and then moving drupal_add_js() and drupal_add_css() in the associated function. This way the hook_form_alter() will contains form elements only, and the #after_build will load Javascript and CSS.
The date_popup module included in the date package allows you to create a calendar widget to add dates. You just need to set the date_popup type to a textbox element, for example:
$form['start_date'] = array(
'#type' => 'date_popup',
'#title' => 'Start date',
'#default_value' => $values['start_date'],
'#date_format' => 'm/d/Y',
'#size' => 13,
);
A click in the textbox will show up a calendar widget to choose the date.
Be careful: DO NOT ADD the #maxlength property to the element, otherwise you will get an error like this:
warning: mb_strlen() expects parameter 1 to be string, array given in D:\localhost\drupal\includes\unicode.inc on line 410.
The error occurs because the date_popup module transforms the date value in an array, so the max length check performed by form validation execues the drupal_strlen function on an array and not a string.
The Node images project is a Drupal module to create photogalleries. It allows users to assign images to content and view those images in a gallery. Users may upload images inline in the content creation page, and then manage them in a specific page, to edit the current images or upload new ones.
Here are the main features of this module:
Photogallery demo: Pictures of Gaeta
$conf['i18n_variables'] = array(
// Site configuration
'site_slogan',
'site_mission',
'anonymous',
// User configuration
'user_registration_help',
'usermail_welcome_subject',
'user_mail_welcome_body',
'user_mail_approval_subject',
'user_mail_approval_body',
'user_mail_pass_subject',
'user_mail_pass_body',
// Primary and secondary links
'menu__primary_links_source',
'menu__secondary_links_source',
// Theme settings. This is an 'all or nothing' for each theme
// This is for 'garland' theme, for other theme it would be 'theme_[themename]_settings'
'theme_garland_settings',
);
global $language;
if (!empty($vars['primary_links'])) {
foreach ((array)$vars['primary_links'] as $id => $link) {
if ($link['langcode'] && strcmp($link['langcode'], $language->language) != 0) unset($vars['primary_links'][$id]);
}
}
