Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get the current view name in CodeIgniter?

How get the name of the current displaying view for pass to another function?

like image 506
vickcontreras Avatar asked Dec 01 '22 23:12

vickcontreras


2 Answers

If you want to display view name within view :

echo $_ci_view;

Also see print_r(get_defined_vars()) you will see many interesting variables from CI.

like image 130
GuramK Avatar answered Dec 04 '22 03:12

GuramK


You could pass the name of the View to the View.

Controller:

$data = array('viewName' => 'home_view');
$this->load->view($data['viewName'], $data);

Then to access in your view you could retrieve the view name with:

<?php echo $viewName ?>
//produces 'home_view'
like image 24
brightintro Avatar answered Dec 04 '22 03:12

brightintro