Including files in 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: Including files in Views (/showthread.php?tid=5525) |
Including files in Views - El Forum - 01-25-2008 [eluser]Unknown[/eluser] Hi there, I've recently begun setting up a website in Code Igniter and have run into a little problem concerning structure/page setup... My problem is that in the Views folder I have a sub-folder called "constants" which holds files such as header.php, navigation.php etc. I also have a number of other sub-folders within the Views folder that hold specific Views pages based on sections of the website. So in essence, my Views folder looks like this: main_view.php constants |-header.php |-footer.php |-nav.php about_view.php some_folder |-some_file.php My problem now comes when I try and link a file from the constants folder (i.e. header.php) into the "some_file.php" file. Code: <?php require_once('../constants/header.php'); ?> Any suggestions would be of great help. Thanks a million in advance, Matt Including files in Views - El Forum - 01-25-2008 [eluser]Craig A Rodway[/eluser] Instead of include(), the preferred method is to use: Code: <?php $this->load->view('constants/header'); ?> Even in your views Including files in Views - El Forum - 01-25-2008 [eluser]Unknown[/eluser] Of course! I don't know why I didn't try that before! Looks like I'm still stuck in procedural coding practices... I have a fair way to go with getting fully to grips with this framework (and method of development) but I'll get there in the end no doubt! Thank you so much Craig, Matt |