If a user updates there profile it save an actual theme name instead of leaving it blank for the default. This means it's no longer possible for a user to "follow the default" if they select the default theme in their user profile. The following orphan code used to fix this scenario, but has been orphaned by the form api changes.
// Reset to follow site default theme if user selects the site default
if ($key == variable_get('theme_default', 'bluemarine')) {
$key = '';
if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) {
$edit['theme'] = '';
}
}
foreach ($themes as $info) {
$info->screenshot = dirname($info->filename) . '/screenshot.png';
$screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');
$form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot);
$form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename));
$options[$info->name] = '';
}
$form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : variable_get('theme_default', 'bluemarine'));
This should be moved inside the for loop and used to set the values for the options box. Here is the code as it should look with the new forms api.
foreach ($themes as $info) {
// Reset to follow site default theme if user selects the site default
if ($info->name == variable_get('theme_default', 'bluemarine')) {
$key = '';
if ($edit['theme'] == variable_get('theme_default', 'bluemarine')) {
$edit['theme'] = '';
}
}
else {
$key = $info->name;
}
$info->screenshot = dirname($info->filename) . '/screenshot.png';
$screenshot = file_exists($info->screenshot) ? theme('image', $info->screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), false) : t('no screenshot');
$form['themes'][$info->name]['screenshot'] = array('#type' => 'markup', '#value' => $screenshot);
$form['themes'][$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename));
$options[$key] = $info->name;
}
$form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $edit['theme'] ? $edit['theme'] : '');
Unfortunatly this exposes a bug in the form api. I will submit a proper patch once the form api handles this correctly.
Comment | File | Size | Author |
---|---|---|---|
#6 | theme_default.patch | 2.65 KB | killes@www.drop.org |
#5 | defaultheme1.patch | 2.56 KB | ccourtne |
#3 | defaultheme.patch | 2.59 KB | ccourtne |
Comments
Comment #1
ccourtne CreditAttribution: ccourtne commentedSome clarification the changes above are in the system_user function inside system.module. And the related bug filed against the form api is node/35227.
Comment #2
Robin Monks CreditAttribution: Robin Monks commentedAny progress on that patch?
Comment #3
ccourtne CreditAttribution: ccourtne commentedThe related bug seems to have been fixed in HEAD so here is the patch.
Comment #4
Robin Monks CreditAttribution: Robin Monks commentedStyle looks good, +1
Robin
Comment #5
ccourtne CreditAttribution: ccourtne commentedUpdating to beta3 and re-rolled patch.
Comment #6
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedre-rolled from base dir without tabs...
Comment #7
Robrecht Jacques CreditAttribution: Robrecht Jacques commentedThis was fixed in system.module v1.313.
Tried it with current CVS/5.0 and when the user selects the default theme, and the admin then changes the default theme, the theme selection of the user will follow that new default.
Comment #8
(not verified) CreditAttribution: commented