Welcome Guest, Not a member yet? Register   Sign In
Problem with view dir change
#1

[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
#2

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

[eluser]InsiteFX[/eluser]
Hi jedd,

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

Enjoy
InsiteFX
#4

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

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

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

[eluser]jrtashjian[/eluser]
Awesome!




Theme © iAndrew 2016 - Forum software by © MyBB