Under 6.13, when I set "Display mode: Random logos" and the Random frequency to something other than every page refresh ie using a time interval the random logo only works once at the start of each interval.

What happens is the logotool code sets the logo in $variables the first time in the time interval and the logo displays. The next time a page is requested within the interval the logo is not set (it thinks it doesn't have to) and no logo displays, or the site/theme logo displays if it is set in the theme or site settings.

The reason for this is that the includes/theme.inc sets the logo variable in $variables to the site default and logotools doesn't override this within the interval (only the first time).

The problem is in this bit of the code:

    case '1':
      if ($time || !variable_get('logotool_frequency', 0)) {
        $logos = logotool_scan_dir(variable_get('logotool_folder', LT_CWD));
        if ($time) {
          variable_set('logotool_timestamp', time());
        }
        $variables['logo'] = sprintf("/%s", array_rand($logos));
      }    
      break;

so if we're within the interval and we don't need to set the next timestamp $variables['logo'] is never set and the theme value is retained.

I'd fix it if I knew how to set a variable that persists but I'm unsure how to do that in the Drupal setting.

Comments

Anonymous’s picture

I've cobbled together a fix for this:

Around line 385 of logotool.module:

    case '1':
        if ($time || !variable_get('logotool_frequency', 0)) {
        $logos = logotool_scan_dir(variable_get('logotool_folder', LT_CWD));
        if ($time) {
          variable_set('logotool_timestamp', time());
        }
        $last_logo = sprintf("/%s", array_rand($logos));
        variable_set('logotool_last_logo', $last_logo);
      }
      $variables['logo'] = variable_get('logotool_last_logo',0);  
      break;

This uses a persistent variable to save the random logo for use in subsequent page refreshes. I'm no drupal programmer but this certainly seems to work for me.

pobster’s picture

Status: Active » Needs review

Thanks, I'll look into this. TBH the reason the 6.x release is still in dev is because I haven't had time to test it at all outside of what I need it to do myself.

Pobster

Anonymous’s picture

Thanks pobster - I'm happy to test any tweaks you make as yours is the only solution I can find for random but time based logos.

For now I'm ok with the fix I made. Thanks for the module.

pobster’s picture

Version: 6.x-1.x-dev » 6.x-2.0-beta1
Status: Needs review » Fixed

Looks fine now for the 2.x release.

Pobster

Status: Fixed » Closed (fixed)

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