Welcome Guest, Not a member yet? Register   Sign In
view not loaded in second function
#1

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);
    }
}
Reply
#2

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

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

shoudl be like this (instead echo) ;

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

echo'ing view is Ok
what would happen if you used
Code:
$data['title'] => 'my profile';
$data['heading'] => 'user data:';
$data['view']     => 'dashboard1';
CMS CI4     I use Arch Linux by the way 

Reply
#5

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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(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!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB