First off, here's my newest module:
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/logotool/logo...
It works fine under the 'normal' and 'random' modes, but when you select 'specifed' mode although it sort of works, I'm having trouble with setting a default logo when a match ISN'T made. Yeah that's right... You'd think that'd be the easiest part? Well that's the part I'm having trouble with...
Here's the code for hook_init:
/**
* Implementation of hook_init
*/
function logotool_init() {
switch (variable_get('logotool_display', 0)) {
case '0':
variable_set('logotool_logo', variable_get('logotool_path', ''));
break;
case '1':
$logos = file_scan_directory(variable_get('logotool_folder', LT_CWD), '.*');
variable_set('logotool_logo', array_rand($logos));
break;
case '2':
$temp = explode("\n", variable_get('logotool_pages', ''));
foreach ($temp as $a) {
$logo[substr($a, 0, strpos($a, '|'))] = trim(variable_get('logotool_folder', LT_CWD).'/'.substr($a, strpos($a, '|')+1));
}
if (array_key_exists($_GET['q'], $logo)) {
variable_set('logotool_logo', $logo[$_GET['q']]);
}
break;
} // end switch
} // logotool_init
Now case '2' is what I need help with and as you can see it currently has no provisions if a match ISN'T made but in this state... it works... Only it displays the same logo as was specified previously when no match is made (obviously). So common programming sense tells me that all I need to do is add an 'else' to the code like this: