Still got the Error

Notice: Undefined offset: 1 in blocktheme_get_blockthemes() (linea 255 di /var/wwwroot/connect_informatics/sites/all/modules/blocktheme/blocktheme.module).

Anyway to avoid it?

Thanks, bye!

Comments

mindhunter75’s picture

Same error here:

Notice: Undefined offset: 1 in blocktheme_get_blockthemes() (regel 255 van /public_html/sites/all/modules/blocktheme/blocktheme.module).
Notice: Undefined offset: 1 in blocktheme_get_blockthemes() (regel 255 van /public_html/sites/all/modules/blocktheme/blocktheme.module).

Xtal’s picture

From what I can see this isn't an issue in the code.
I found by adding a dpm for the options like so:

function blocktheme_get_blockthemes() {
  $options = array();
  $blockthemes = variable_get('blocktheme_themes', '');

  $options[] = t('- None -');

  if ($blockthemes) {
    $_sets = explode("\n", $blockthemes);

    foreach ($_sets as $key => $value) {
      $set = explode('|', $value);
      $options[$set[0]] = $set[1];
    }
  }
  dpm($options);
  return $options;
}

You can see the array of options like so:

a dpm array

In my case you can see the last item in the array is NULL. This means there is a value that shouldn't be there.
I found I had an extra blank line in config section where you declare the settings, eg:

default|Default
graybg|Gray
primarybg|Purple
(extra return was here)

Removing this extra line will solve the issue.

Furthermore here is a patch that will check if $set[1] actually has a value init with the following change:

if(isset($set[1])){
  $options[$set[0]] = $set[1];
}
Xtal’s picture

Status: Active » Needs review
astonvictor’s picture

Status: Needs review » Closed (works as designed)

Close the issue because it is related to incorrect input data. Don't use additional empty lines and follow the next format: default|Default.