• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->load->view from relative path.

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

#2
[eluser]xwero[/eluser]
the start of the view path is set in the load->_ci_view_path variable so you can do
Code:
$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.

#3
[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...

#4
[eluser]xwero[/eluser]
Colin you are right i was mixing it up with the relative paths of assets.

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.