Friday, 11 October 2013

Drupal7 customizing theme part.1


Customizing theme is not so hard if you understand the structure of php files in theme folder.
I added the setting for the body width.
First, I added the setting of "body_width" in .info file.
------------------------------------------------------------------------------------------
<xxx.info>
; Settings
settings[body_width] = 75%
------------------------------------------------------------------------------------------
Then, I wrote the code which prompts users to enter the setting values in theme-settings.php.
------------------------------------------------------------------------------------------
<theme-settings.php>
function holiday_form_system_theme_settings_alter(&$form, $form_state) {
$form['theme_settings']['body_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Body width'),
    '#default_value'   => theme_get_setting('body_width'),
    '#size' => 12,
    '#maxlength' => 8,
    '#element_validate' => array('holiday_body_width_validate'),
);
}
------------------------------------------------------------------------------------------
After that, go to "Appearance" menu, click the setting of your theme. you'll see "Body width" setting.

.

No comments:

Post a Comment