2013-03-18, 08:02 PM
Hi, I have a custom header that needs to display different information depending on whether or not a user is logged in.
I have inserted my header code into the 'header' template, and all the HTML comes out fine. The php, 'if-else' part does not though.
This is the basically the code I need:
and this is what that outputs:
Login'; } else { echo'Logout';}?>
Can we use PHP code in the templates? If not, how can get this conditional behavior to work?
Thanks
I have inserted my header code into the 'header' template, and all the HTML comes out fine. The php, 'if-else' part does not though.
This is the basically the code I need:
<?php
if(!$mybb->user['uid']){ //if user is not logged in
echo '<li><a href="http://mysite.com/forums/member.php?action=login">Login</a></li>';
} else {
echo '<li><a href="/forums/member.php?action=logout&logoutkey='.{$mybb->user['logoutkey']}'">Logout</a></li>';
}
?>
and this is what that outputs:
Login'; } else { echo'Logout';}?>
Can we use PHP code in the templates? If not, how can get this conditional behavior to work?
Thanks