Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: SleePy - helmikuu 21, 2006, 10:35:19 IP

Otsikko: how do i call a user option from index template?
Kirjoitti: SleePy - helmikuu 21, 2006, 10:35:19 IP
i run a random banner code on our site and want to give options because some people are having trouble with it.
everything is good :) i was able to add a drop down to profile with options. but now i can't seem to get it to find it.


if(empty($context['user']['options']['randombanner'])) {$context['user']['options']['randombanner'] = '1';}
if($context['user']['options']['randombanner'] == 1){echo '<img src="/forums/banners/index.php" height="200" width="800" />';}
elseif($context['user']['options']['randombanner'] == 2){$randomnumber = rand(1, 8); echo '<img src="/forums/banners/banner'.$randomnumber.'.jpg" height="200" width="800" />';}
elseif($context['user']['options']['randombanner'] == 3){echo '<img src="/forums/banners/banner1.jpg" height="200" width="800" />';}


i have it set to 2 or 3 in my profile and 3 is to show a default image. but go to any other page than profile and i instantly lose it and it reverts back to 1. meaning to me it can't find $context['user']['options']['randombanner']
i tried
$context['member']['options']['randombanner']
$options['randombanner']
$settings['randombanner']
and nothing is working... I don't understand why it isn't working
Otsikko: Re: how do i call a user option from index template?
Kirjoitti: Dannii - helmikuu 21, 2006, 10:39:23 IP
It's probably going to be in $user_info
you're saving this setting in the members table? Just look where you have loaded it from the database and that will tell you exactly where.
Otsikko: Re: how do i call a user option from index template?
Kirjoitti: SleePy - helmikuu 21, 2006, 10:44:26 IP
well i think its stored in the themes table because this is how i did the settings in profile template


</tr><tr><td><b>Random Banner: </b></td> <td><select name="default_options[randombanner]" ><option value="1"'; if($context['member']['options']['randombanner'] == 1){echo ' selected="selected"';}echo'>Normal </option><option value="2"'; if($context['member']['options']['randombanner'] == 2){echo ' selected="selected"';}echo'>Dial Up</option><option value="3"'; if($context['member']['options']['randombanner'] == 3){echo ' selected="selected"';}echo'>No Random</option></select> - If "No Random is selected a default one will be used instead.</td>


btw. how can i do a better way of finding if the option is selected? i tried using the one that is used on smilies set but couldn't get it to work.