CodeIgniter Forums
get files/name of loaded views - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: get files/name of loaded views (/showthread.php?tid=19720)



get files/name of loaded views - El Forum - 06-16-2009

[eluser]bas_vdl[/eluser]
Hello,

is there a way to get an array with the actual loaded views.

i want to check if view (search/form) is loaded in my template file so i can load the javascript files only when needed.

thank you


get files/name of loaded views - El Forum - 06-16-2009

[eluser]slowgary[/eluser]
I'm not sure but couldn't you just put the javascript into the view that requires it?

You could also just define() a constant in each view:
Code:
if(!defined('header_view'))
{
     define('header_view');
}

Then in another view...
Code:
if(defined('header_view'))
{
     echo "< script type='text/javascript' src='library.js' >< /script >";
}

You can also use get_defined_constants(), which will return an associative array of defined constants.