Example #1
0
/**
* Implementation of THEMEHOOK_settings() function.
*
* @param $saved_settings
*   array An array of saved settings for this theme.
* @return
*   array A form array.
*/
function phptemplate_settings($saved_settings)
{
    /*
     * The default values for the theme variables. Make sure $defaults exactly
     * matches the $defaults in the template.php file.
     */
    $defaults = array('pixture_width' => '85%');
    // Reset to default value if the user specified setting is invalid
    $saved_width = $saved_settings['pixture_width'];
    $saved_settings['pixture_width'] = _validate_page_width($saved_width);
    // Merge the saved variables and their default values
    $settings = array_merge($defaults, $saved_settings);
    // Create the form widgets using Forms API
    $form['pixture_width'] = array('#type' => 'textfield', '#title' => t('Page width'), '#default_value' => $settings['pixture_width'], '#size' => 12, '#maxlength' => 8, '#description' => t('Specify the page width in percent ratio (50-100%) for liquid layout, or in px (800-1600px) for fixed width layout. If an invalid value is specified, the default value (85%) is used instead. You can leave this field blank to use the default value. You need to add either % or px after the number.'));
    // Return the additional form widgets
    return $form;
}
Example #2
0
/**
 * @file
 *  theme-settings.php
 *
 * Implementation of THEMEHOOK_settings() function.
 *
 * @param $saved_settings
 *   array An array of saved settings for this theme.
 * @return
 *   array A form array.
 */
function phptemplate_settings($saved_settings)
{
    /*
     * The default values for the theme variables. Make sure $defaults exactly
     * matches the $defaults in the template.php file.
     */
    $defaults = array('pixture_width' => '85%', 'pixture_superfish' => 0, 'pixture_searchlabel' => 0);
    // Reset to default value if the user specified setting is invalid
    $saved_width = $saved_settings['pixture_width'];
    $saved_settings['pixture_width'] = _validate_page_width($saved_width);
    // Merge the saved variables and their default values
    $settings = array_merge($defaults, $saved_settings);
    // Create the form widgets using Forms API
    $form['pixture_width'] = array('#type' => 'textfield', '#title' => t('Page width'), '#default_value' => $settings['pixture_width'], '#size' => 12, '#maxlength' => 8, '#description' => t('Specify the page width in percent ratio (50-100%) for liquid layout, or in px (800-1600px) for fixed width layout. If an invalid value is specified, the default value (85%) is used instead. You can leave this field blank to use the default value. You need to add either % or px after the number.'));
    $form['pixture_superfish'] = array('#type' => 'checkbox', '#title' => t('Enable Superfish Drop Menus'), '#default_value' => $settings['pixture_superfish'], '#description' => t('Check this setting to enable support for Superfish drop menus. NOTE: In order for the drop menu to show you MUST uncheck Primary links in the "Toggle display" settings. See the README for full instructions.'));
    // Return the additional form widgets
    return $form;
}