CodeIgniter Forums
Problem with view dir change - 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: Problem with view dir change (/showthread.php?tid=21904)



Problem with view dir change - El Forum - 08-24-2009

[eluser]walrus_lt[/eluser]
Hi, i have problem while trying to change view dir;
In my cron library i puted this code:
Code:
function check_browser(){
    $this->ci->load->library('user_agent');

    if ( $this->ci->agent->is_mobile() ){
        $this->ci->CI_Loader->_ci_view_path = APPPATH.'views/mobile/';
    } else {
        $this->ci->CI_Loader->_ci_view_path = APPPATH.'views/desktop/';
    }
}

But it throws error that it doesnt find my view file. Anyone could help me please? Smile


Problem with view dir change - El Forum - 08-24-2009

[eluser]jedd[/eluser]
What is APPPATH?


Problem with view dir change - El Forum - 08-24-2009

[eluser]InsiteFX[/eluser]
Hi jedd,

APPATH is defined in the index.php file and it points to the CI application directory.

Enjoy
InsiteFX


Problem with view dir change - El Forum - 08-24-2009

[eluser]jedd[/eluser]
Yes. Quite. Indeed.

I meant it more as a 'what does this resolve to?' question, asked in a 'take these pebbles from my hand, grasshopper' style.

These kinds of bugs (ha ha) are usually very easily resolved by a judicious use of an echo/var_dump, and/or (if it gets a little further) checking the page-source of the resultant web page.

Or, if you prefer, 'teach a man how to fish ...'. I'm sure there are numerous other pithy aphorisms that could be applied here.


Problem with view dir change - El Forum - 08-24-2009

[eluser]jrtashjian[/eluser]
Try this:

Code:
$this->load->_ci_view_path = $this->load->_ci_view_path . 'mobile/';
$this->load->_ci_view_path = $this->load->_ci_view_path . 'desktop/';

$this->load->_ci_view_path returns "application/views/" so there should be no need to grab the APP_PATH.

Let me know how that works out for you.


Problem with view dir change - El Forum - 08-25-2009

[eluser]walrus_lt[/eluser]
[quote author="jrtashjian" date="1251182160"]Try this:

Code:
$this->load->_ci_view_path = $this->load->_ci_view_path . 'mobile/';
$this->load->_ci_view_path = $this->load->_ci_view_path . 'desktop/';

$this->load->_ci_view_path returns "application/views/" so there should be no need to grab the APP_PATH.

Let me know how that works out for you.[/quote]

Works perfectly! Wink


Problem with view dir change - El Forum - 08-25-2009

[eluser]jrtashjian[/eluser]
Awesome!