• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if (!$logged_in) { $this->load->view('login'); }

#1
[eluser]bwuk[/eluser]
Hi everyone,

basically the title explains what it is I'm trying to do....but here's the extra info:

I've extended Controller with the following:


Code:
class Public_Controller extends Controller {
    public $header_js = array();
    public $header_css = array();
    public $data = array();
    
      function __construct() {
        parent::Controller();
        
        $this->header_css[] = array('href' => '/media.css', 'media' => 'all', 'compress' => true);
        
        $this->load->library('user_lib');
        
        $this->load->library('apps_lib');
        $this->load->helper('email');
        
        if ($this->load_main_content())
        {
            $this->display_top_nav();
            $this->display_top_menu();
            
            if ($this->user_lib->getUserId() > 0)
            {
                $this->display_homepage();
            }
        }
    }


    private function display_top_nav()
    {
        $this->load->view('top_nav');
    }
    
    
    private function display_top_menu()
    {
        $this->load->view('top_menu');
    }
    
    
    private function display_homepage()
    {
        if ($this->user_lib->getUserId() == 0)
        {
            $this->header_css[] = array('href' => '/login.css', 'media' => 'all', 'compress' => true);
            $this->load->view('/login');
            
// I want to exit at this point
        }
    }


Basically, if someone isn't logged in, I want to display the view 'home' and stop everything there. I've also extended Output with MY_Output that deals with page headers and 'skins'. My site uses 'skins', which are basic templates. Here's one for example:

'skin.php'

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;page_title />&lt;/title&gt;

&lt;header_css /&gt;

&lt;/head&gt;

&lt;body&gt;

<div id="container">
    
<output />

</div>

&lt;header_js /&gt;

&lt;/body&gt;
&lt;/html&gt;


So, MY_Output deals with:
<page_title /> - set in each Controller with $this->page_title
&lt;header_css /&gt; - set in each Controller with $this->header_css[] (an array of CSS includes)
<output /> - The standard output
&lt;header_js /&gt; - set in each Controller with $this->header_js[] (an array of JS includes)


How can I get CI to load the home view and then stop processing - i.e. just output the view with the relevant headers from MY_Output? If I try $this->output->get_output(), it just returns the standard output (what would replace <output /> in my skin).


Does that make any sense? Wink


Thanks

bwuk


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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