Welcome Guest, Not a member yet? Register   Sign In
disable/hide button using condition in controller
#2

If you are not already using views, you should consider it, but here's a simple example how to pass data to view and then in view display different HTML, depending on values.

Controller:
PHP Code:
public function index()
{
    
// ...

    
$showRegistrationButtonfalse;

    
// data to pass to view
    
$data = [
        
'showRegistrationButton' => $showRegistrationButton,
        
'pageTitle' => 'My page title'
    
];

    
$this->load->view('myview'$data);


View file:
PHP Code:
<h1><?= $pageTitle ?></h1>
<?php if ($showRegistrationButton) : ?>
    <a href="<?= site_url('registration-controller'?>">Register</a>
<?php else: ?>
    <div>Already registered</div>
<?php endif ?>
Reply


Messages In This Thread
RE: disable/hide button using condition in controller - by Pertti - 07-10-2018, 11:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB