Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Elmacik - joulukuu 11, 2005, 08:08:25 IP

Otsikko: How to check current category?
Kirjoitti: Elmacik - joulukuu 11, 2005, 08:08:25 IP
For example I want to display some special things when the user is in "bla bla" category..
How to check it ?
Very clumsily I tried:
if ($context['boards']['id'] == 1)
Didnt work..
Otsikko: Re: How to check current category?
Kirjoitti: Thantos - joulukuu 11, 2005, 08:15:26 IP
When on the message index:
$context['linktree'][1]['name'] will get you the category name
if you need the id:
$catid = explode('#', $context['linktree'][1]['url']);
$catid = $catid[1];
Otsikko: Re: How to check current category?
Kirjoitti: Elmacik - joulukuu 11, 2005, 09:23:19 IP
MikeMill,
Thanks a lot but I asked the question wrong I think.. Sorry.
I wanted to do it for a spesific board (and not a category)

For example if the user is in board 3, he/she will see something like "you are viewing board 3"
Otsikko: Re: How to check current category?
Kirjoitti: Thantos - joulukuu 11, 2005, 09:36:25 IP
Oh :)
$context['current_board']
Otsikko: Re: How to check current category?
Kirjoitti: Elmacik - joulukuu 11, 2005, 09:45:57 IP
Thanks MikeMill..
But I couldnt achieve to check it :(
if ($context['current_board']['id'] == 3) echo 'bla bla bla';

Whats wrong with it then?
Otsikko: Re: How to check current category?
Kirjoitti: Thantos - joulukuu 11, 2005, 09:54:31 IP
if ( $context['current_board'] == 3 )
Otsikko: Re: How to check current category?
Kirjoitti: Elmacik - joulukuu 11, 2005, 09:57:55 IP
What do I get wrong? I had tried it but didnt work.. Now its ok.. How stupid I am >:(
MikeMill, thanks a lot..