Welcome Guest, Not a member yet? Register   Sign In
relative paths in view files, can't include view files
#1

[eluser]LAMP Coder[/eluser]
I'm trying to organize my view files into folders, following is the directory structure

Code:
Views
- CommonFiles
    - header.php
    - footer.php
- Section1
    - section1_index.php
- Section2


now, when i try to include header.php in section1_index.php it doesn't work.

I've tried following:
1.
Code:
include 'CommonFiles/header.php';
2.
Code:
include '../CommonFiles/header.php';

Neither of them work, I'm not sure what I'm doing wrong..
#2

[eluser]Dam1an[/eluser]
Either of the following should work
Code:
include APPPATH.'views/CommonFiles/header.php';
or
$this->load->view('CommonFiles/header');

Also, for consistency with the CI guidelines, it's recommended to use all lower case and underscores then camelcase




Theme © iAndrew 2016 - Forum software by © MyBB