I know this is a weird question, but let me explain more. I use codeigniter as framework to make my site. I have some code that contain if else condition in view and want to use that as a href so it becomes like a button that changes based on whether the condition has been met or not.
here is the code:
<?php if($this->tank_auth->is_logged_in())
{ echo anchor("auth/logout/","Logout");
} else {
echo anchor("auth/login/","Login");
?>
I was looking around in the net, but couldn’t find a similar case where if else statement being used.
any idea how to achieve that?
Thanks
That should work fine, as long as
tank_authis loaded and you have a closing bracket after yourelsecondition:You might also consider moving your check for the user’s login to your controller, however, so as to keep
tank_authout of your views:In this case, you would then run your conditional on
$logged_inin your view.