Search code examples
phppluginsvbulletin

vBulletin elseif not working in plugins


I run vBulletin 4.2.1 and I am having some problems with getting elseif's working in plugins.

This is my code for my plug in:

if (in_array($GLOBALS['forumid'], array(5,13,10,43))) {

    $my_str= 'http://th07.deviantart.net/fs70/PRE/f/2014/196/a/c/forum_background_striking_family_by_dontpanic13-d7qvlp9.jpg';

}elseif (in_array($GLOBALS['forumid'], array(2,6,24,11))) {

    $my_str='http://th08.deviantart.net/fs70/PRE/f/2014/196/c/7/forum_background_bound_by_dontpanic13-d7qvlo2.jpg';

}elseif (in_array($GLOBALS['forumid'], array(4,9,12,25))) {

    $my_str='http://th04.deviantart.net/fs70/PRE/f/2014/196/2/3/forum_background_rising_by_dontpanic13-d7qvlok.jpg'

}else{

    $my_str= 'http://oi57.tinypic.com/2hfm8tl.jpg';

}

$mytemplater = vB_Template::create('additional.css');
$mytemplater->register('my_str', $my_str);
$myrendervar = $mytemplater->render();
vB_Template::preRegister('additional.css',array('my_str' => $my_str));


$mytemplater = vB_Template::create('headinclude');
$mytemplater->register('my_str', $my_str);
$myrendervar = $mytemplater->render();
vB_Template::preRegister('headinclude',array('my_str' => $my_str));

It works if I just have the first if and then the last else but as soon as I add all the elseif's in it stopped working. What am I doing wrong? It all worked without the elseif so there is something wrong with them but I don't know what it is or how to fix it.

I would appreciate help on this.

Thank You.


Solution

  • You forgot to add semicolon in second elseif. It should be:

    if (in_array($GLOBALS['forumid'], array(5,13,10,43))) {
    
        $my_str= 'http://th07.deviantart.net/fs70/PRE/f/2014/196/a/c/forum_background_striking_family_by_dontpanic13-d7qvlp9.jpg';
    
    }elseif (in_array($GLOBALS['forumid'], array(2,6,24,11))) {
    
        $my_str='http://th08.deviantart.net/fs70/PRE/f/2014/196/c/7/forum_background_bound_by_dontpanic13-d7qvlo2.jpg';
    
    }elseif (in_array($GLOBALS['forumid'], array(4,9,12,25))) {
    
        $my_str='http://th04.deviantart.net/fs70/PRE/f/2014/196/2/3/forum_background_rising_by_dontpanic13-d7qvlok.jpg'; // semicolon added here
    
    }else{
    
        $my_str= 'http://oi57.tinypic.com/2hfm8tl.jpg';
    
    }