Welcome Guest, Not a member yet? Register   Sign In
Loading views outside of normal view and module/view folders
#1
Question 
(This post was last modified: 06-03-2016, 01:46 PM by RogerMore.)

Hi guys,

I can use some help with the following:

I'm developing a custom CMS for a client with CI 3 and HMVC. 
What I really want to achieve, is that I can load views outside the normal view or module/view folders. This because I want to give the client the opportunity to choose a theme for a certain page, so that I can load out of the root/themes/chosen_theme folder a page template view. Every theme folder holds the page templates, and folders like css and js because every theme can use their own seperated set of css and js files. It's a lot like the wp-content/themes folder which can hold several themes with their own css and js folders.

I tried the following:

PHP Code:
function ext_view($folder$view$vars = array(), $return FALSE) {
    
$this->_ci_view_paths array_merge($this->_ci_view_paths, array(FCPATH $folder '/' => TRUE));
    return 
$this->_ci_load(array(
        
'_ci_view' => $view,
        
'_ci_vars' => $this->_ci_object_to_array($vars),
        
'_ci_return' => $return
    
));

I called ext_view like below and followed all data and it seems fine. 
PHP Code:
$this->load->ext_view('themes''standard/index'); 

I'm not getting any errors. Only when I make some deliberate typos in the folder or view name, I get the expected CI errors like "Unable to load the requested file: standard/index.php". I's like the output buffer code is not working with my template. But when putting an echo "test" at the end of the _ci_load function, "test" is echoed to the screen.  
Huh

Has anyone tried something similar or has any ideas how to load a view outside the normal view and module/view folders?

Thanks in advance,
-Roger
Reply
#2

If you look at the index.php code you will see that you can set your own view path in it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Hi InsiteFX,

Thanks for your respons!

Ouch! Didn't know I could set my own path... Is it new with CI 3? I can't remember such a setting in CI 2?

Thanks anyways! This wil certainly do the trick!

Greeting,
-Roger
Reply




Theme © iAndrew 2016 - Forum software by © MyBB