CVS edit link for jemmyw2

I would like to submit and maintain a module I have written called linkedtheme. It allows linking one theme to another in order to synchronize block settings between the two themes. It is similar to blockregion, but differs in that blockregion copies blocks to all themes.
CommentFileSizeAuthor
#9 linkedtheme.zip4.63 KBjemmyw2
#5 linkedtheme.zip4.42 KBjemmyw2
#2 linkedtheme.zip4.49 KBjemmyw2

Comments

avpaderno’s picture

Why didn't you open a feature request for that module, or created a patch?

jemmyw2’s picture

StatusFileSize
new4.49 KB

After looking through the code for blockregion I felt that the functionality I needed was sufficiently different to start a new module.

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Module review

Remember to change the status, when you upload new code.

avpaderno’s picture

Status: Needs review » Needs work
  1. See the Drupal coding standards to understand how a module code should be written. The coding standards also report which Unicode functions should be used from the module.
  2.   if ($form_id == 'system_theme_settings') { // Theme settings form
        $current_theme = $form['#parameters'][2];
    

    That is not the correct way to get the theme for which the settings should be applied.

  3.     $sql = "INSERT INTO {blocks} (status, weight, custom, throttle, visibility, pages, title, cache, module, delta, theme, region)";
        $sql .= " VALUES(";
        $sql .= str_repeat("'%s',", 11);
        $sql .= "'%s')";
    

    There is a Drupal function that should be used to get the placeholders of many arguments; the code could then use drupal_write_record().

  4.   $schema['linkedtheme'] = array(
        'description' => t('Stores linked themes'),
        'fields' => array(
          'linkedtheme_id' => array(
            'description' => t("Unique identifier for each linked theme."),
            'type' => 'serial',
            'not null' => TRUE,
            'no export' => TRUE
          ),
          'theme' => array(
              'description' => t("Name of the theme"),
    

    Schema descriptions should not be passed to t() anymore. See system_schema() for an example of what done by Drupal core code.

jemmyw2’s picture

Status: Needs work » Needs review
StatusFileSize
new4.42 KB

Thanks for your feedback, I've addressed all of the described issues except for number 2: I'm not sure what the correct way to fetch the theme in this function as referred to here. Could you provide a hint on a better way to fetch form arguments from form_alter?

avpaderno’s picture

There a value contained in $form that can be used (it is something like $form['#key']). I know that because I once created a custom module that I used to alter the theme settings page, but unfortunately I have not the code anymore, as the most important change I was trying to make was not working.
I can tell you that such value must be modified, and it is the exact contrary operation that system.module does.

jemmyw2’s picture

Looking at a var_dump of $form the only place I see the name of the theme is in $form['#parameters']. Following the code through from drupal_get_form this seems to be where the original unmodified form arguments are stored.

avpaderno’s picture

Status: Needs review » Needs work

$form['#parameters'] is added from Drupal core code and, as it is not declared in any API documentation, it should not be used, also because it is not said that what the code should use is always in $form['#parameters'][2].

The correct way to proceed, for the theme settings form, is to use the value contained in $form['var']['#value'], as it also done from Theme Settings API.

function themesettingsapi_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'system_theme_settings':
      // Grab the specific name of the theme settings form
      $key = $form['var']['#value'];
      $key = ($key == 'theme_settings') ? '' : str_replace(array('theme_', '_settings'), array('', ''), $key);

      // Since we are allowing more settings, make logo and favicon collapsible
      if (empty($key)) {
        // Fix for small bug in Drupal core
        $form['theme_settings']['#prefix'] = '<div class="clear-block">'. $form['theme_settings']['#prefix'];
        $form['node_info']['#suffix'] = $form['node_info']['#suffix'] .'</div>';
        if (isset($form['logo'])) {
          unset($form['logo']['#attributes']['class']);
        }
      }

  // …

}
jemmyw2’s picture

Status: Needs work » Needs review
StatusFileSize
new4.63 KB

Thanks, thats great, I've updated the module to use the correct method of getting the theme name.

avpaderno’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -Module review

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

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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