Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Overturehd - marraskuu 27, 2013, 01:59:34 AP

Otsikko: How to make this work??
Kirjoitti: Overturehd - marraskuu 27, 2013, 01:59:34 AP
Alright so what I am trying to do is make this sub navigation button send you to a different page if you are not logged in on the forums.

'sub_download' => array(
'title' => 'Downloads',
'href' => $scripturl . '?page=page255',
'show' => $user_info['is_guest'],
else
'href' => $scripturl . '?page=downloads',
'show' => true,
),


I tried this going off how I would do it in java but this isn't java lol and I am lost.

Please help!
Otsikko: Re: How to make this work??
Kirjoitti: Kindred - marraskuu 27, 2013, 10:20:49 AP
you can't use conditionals like that in the middle of the array...


'sub_download1' => array(
'title' => 'Downloads',
'href' => $scripturl . '?page=page255',
'show' => $user_info['is_guest'],
),
'sub_download2' => array(
'title' => 'Downloads',
'href' => $scripturl . '?page=downloads',
'show' => !$user_info['is_guest'],
),
Otsikko: Re: How to make this work??
Kirjoitti: Arantor - marraskuu 27, 2013, 10:37:03 AP
You can use inline conditionals though.

'sub_download' => array(
'title' => 'Downloads',
'href' => $user_info['is_guest'] ? $scripturl . '?page=page255' : $scripturl . '?page=downloads',
'show' => true,
),
Otsikko: Re: How to make this work??
Kirjoitti: Kindred - marraskuu 27, 2013, 11:22:02 AP
AH!  Right...    I always forget about those.

That's why you're a developer and I'm a manager. lol....