hipp0
New Member
Posts: 40
inherit
261248
0
Jul 2, 2020 4:25:52 GMT -8
hipp0
40
May 2020
hipp0
|
Post by hipp0 on May 25, 2020 14:54:58 GMT -8
Forum URL: zzz-starborne.proboards.comI am trying to make a little red dot for offline, and green dot for online:
{if $[user.is_online]}<br /><span class="italic"><img src="//storage.proboards.com/7146953/images/JcBPnHxZpqkGzKOhrRcQ.png"></img> Online</span>{/if} {if $[user.is_offline]}<br /><span class="italic"><img src="//storage.proboards.com/7146953/images/DkKMjVjagrhdLLAyCNzR.png"></img> Offline</span>{/if} </div><br /> {/if}
heres my current code, doesn't look right. The online works.
|
|
inherit
252032
0
Apr 4, 2024 21:43:14 GMT -8
Retread
Tribbial Pursuit.
5,014
January 2018
retread
|
Post by Retread on May 25, 2020 18:00:26 GMT -8
Forum URL: zzz-starborne.proboards.comI am trying to make a little red dot for offline, and green dot for online: {if $[user.is_online]}<br /><span class="italic"><img src="//storage.proboards.com/7146953/images/JcBPnHxZpqkGzKOhrRcQ.png"></img> Online</span>{/if} {if $[user.is_offline]}<br /><span class="italic"><img src="//storage.proboards.com/7146953/images/DkKMjVjagrhdLLAyCNzR.png"></img> Offline</span>{/if} </div><br /> {/if} heres my current code, doesn't look right. The online works.
hipp0 , the reason the Offline part doesn't work is because the layout template variable you're using as part of the decision making process, doesn't exist. You can't just make up variable names. The variable must exist and also be valid on the particular template on which you use them. You could just reuse the $[user.is_online] and test if it returns false. But it would be more streamlined to just use it once. Instead of closing the first part with {/if}, leave the loop open for now and add an {else} for the second part. Then close the if loop after that. Like this ... {if $[user.is_online]} <br /><span class="italic"><img src="//storage.proboards.com/7146953/images/JcBPnHxZpqkGzKOhrRcQ.png"></img> Online</span> {else} <br /><span class="italic"><img src="//storage.proboards.com/7146953/images/DkKMjVjagrhdLLAyCNzR.png"></img> Offline</span> {/if}
|
|
hipp0
New Member
Posts: 40
inherit
261248
0
Jul 2, 2020 4:25:52 GMT -8
hipp0
40
May 2020
hipp0
|
Post by hipp0 on May 25, 2020 18:17:46 GMT -8
Thanks worked like a charm, and sorry I don't know code that well. I am just good at finding where stuff needs to go usually and googling answers.
|
|
inherit
140147
0
Apr 20, 2024 22:11:25 GMT -8
Nscalerr 🐺
Throw me to the wolves and I'll return leading the pack!
3,003
May 2009
nscalerr
|
Post by Nscalerr 🐺 on May 26, 2020 1:48:49 GMT -8
Just quickly Retread you don't need the </img> as there is no such tag! More accuate code below. {if $[user.is_online]} <br /><span class="italic"><img src="//storage.proboards.com/7146953/images/JcBPnHxZpqkGzKOhrRcQ.png" /> Online</span> {else} <br /><span class="italic"><img src="//storage.proboards.com/7146953/images/DkKMjVjagrhdLLAyCNzR.png" /> Offline</span> {/if}
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,779
January 2015
msg
|
Post by Lynx on May 26, 2020 4:51:22 GMT -8
As a note, hipp0, when you are in your admin panel and in the templates area, there is a list of valid template variables for that template. For example, if you went to the Home template ( Admin > Themes > Layout Templates > Home), the list of template variables on the right side are valid for the Home template. You can look through the list to see if what you need is there. Also note that, if you can't find an "opposite", you can always use the "not" on it. For example, you have a $[user.is_online], but (as stated above), there is no such variable as $[user.is_offline]. If you want to check specifically if a user is not online (they are offline), you could use !$[user.is_online] - note the ! in front of the variable. That's basically saying "if the user is not online".
|
|