Welcome Guest, Not a member yet? Register   Sign In
$this->load->view from relative path.

[eluser]Moon 111[/eluser]
Is it possible to execute $this->load->view($path) where $path is a relative path?

the start of the view path is set in the load->_ci_view_path variable so you can do
$this->load->_ci_view_path = './views/';
You could use a relative path but i wouldn't recommend it because the relative path is related to the url so if the url changes later on you have to change the _ci_view_path too.

[eluser]Colin Williams[/eluser]
Quote:because the relative path is related to the url

Actually, no it isn't. The request doesn't come from a client, it's happening server-side. It will relative to the location of the script being executed, which is typically index.php, the front controller. At least that's what I think this morning before tea or coffee...

Colin you are right i was mixing it up with the relative paths of assets.

[eluser]Phil Sturgeon[/eluser]
I have called views with the following and it works fine (where themes is a folder next to views).

$this->load->views('../themes/whatever/layout.php', $data);

Theme © iAndrew 2016 - Forum software by © MyBB