Attached patch allows for custom or theme-specific settings without having to alter theme-settings.php and template.php. To do so it will search for a theme-settings-custom.php which contains the phptemplate_settings_custom function. Using this function you can alter $form. Here an example of such a theme-settings-custom.php:

<?php
function phptemplate_settings_custom($form) {
  $form['tnt_container']['seo']['meta']['#description'] = "test";
  return $form;
}

Comments

wmostrey’s picture

StatusFileSize
new928 bytes

Here is an updated version of the patch since we will also need $settings. Here an example of a theme-settings-custom.php:

<?php
function phptemplate_settings_custom($form, $settings) {
  $form['tnt_container']['seo']['meta']['#description'] = "test";
  return $form;
}
sociotech’s picture

Wim, how does this approach deal with the need for a matching reference for each theme setting in template.php theme initialization section as well?

wmostrey’s picture

Hi Chris,

Since the idea is to have the same template.php for each theme we can't add the option there. Take a look at this theme-settings-custom.php. Here's a consequence of having the same template.php with no defaults for the custom options:

'#default_value' => $settings['theme_width'] ? $settings['theme_width'] : 'fixed'

In most cases you will do something similar in page.tpl.php: setting the default value there instead of setting it in template.php.

domesticat’s picture

FYI - patch will need a reroll for anyone using 6.x-dev versions from February 13 and later.

wmostrey’s picture

StatusFileSize
new929 bytes

Here is a re-roll of the patch for the latest dev version.

wmostrey’s picture

StatusFileSize
new2.58 KB

Here's another take, taking comment #2 into account: we add an extra function and a function call to template.php and theme-settings.php. Would this be a better solution than adding the code to page.tpl.php?

Here is an example theme-settings-custom.php:

<?php
function phptemplate_settings_custom_defaults($defaults) {
  $defaults['mydefault1'] = FALSE;
  $defaults['mydefault2'] = "fixed";
  return $defaults;
}

function phptemplate_settings_custom_settings($form, $settings) {
  $form['tnt_container']['seo']['meta']['#description'] = "test";
  return $form;
}
jwolf’s picture

Status: Needs review » Fixed

Thanks Wim!

This is in the 2.x branch

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.