CodeIgniter Forums
view not loaded in second function - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: view not loaded in second function (/showthread.php?tid=87743)



view not loaded in second function - JanFromHamburg - 05-26-2023

I can't explian why the profile() function just ends up in a white page.
Could someone explain or give me a hint to check for something?
PHP Code:
Routes:

$routes->group('employee', static function ($routes) {
    $routes->get('/''Org\Employee::index');
    $routes->get('profile''Org\Employee::profile');
    });

Controller
Code:
namespace App\Controllers\Org;
use App\Controllers\BaseController;

class Employee extends BaseController
{
public function index()  // perfectly working!
    {
        $data = [];
$data['title'] = 'my profile';
$data['heading'] = 'user data:';
$data['view']     = 'dashboard1';
    echo view('design1/template', $data);
        //return redirect()->to(base_url());
    }
   
public function profile()  // just a white page
    { 
        // echo "test route successfull!";  /* (route tested: working!)
        $data = [];
$data['title'] = 'my profile';
$data['heading'] = 'user data:';
$data['view']     = 'dashboard1';
    echo view('design1/template', $data);
    }
}



RE: view not loaded in second function - JustJohnQ - 05-27-2023

Do you get any feedback from F12 - development tools in your browser?


RE: view not loaded in second function - ikesela - 05-27-2023

echo view('design1/template', $data);

shoudl be like this (instead echo) ;

return view('design1/template', $data);


RE: view not loaded in second function - captain-sensible - 05-27-2023

echo'ing view is Ok
what would happen if you used
Code:
$data['title'] => 'my profile';
$data['heading'] => 'user data:';
$data['view']     => 'dashboard1';



RE: view not loaded in second function - InsiteFX - 05-28-2023

You may need to use the saveData option on your views to clear them out. ( 
PHP Code:
[saveData => false]  
)

CodeIgniter 4 User Guide -> Views -> The saveData Option


RE: view not loaded in second function - JanFromHamburg - 05-29-2023

(05-28-2023, 11:02 PM)InsiteFX Wrote: You may need to use the saveData option on your views to clear them out. ( 
PHP Code:
[saveData => false]  
)

CodeIgniter 4 User Guide -> Views -> The saveData Option
wow! Thank You!