CodeIgniter Forums

Full Version: if (!$logged_in) { $this->load->view('login'); }
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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:

class Public_Controller extends Controller {
    public $header_js = array();
    public $header_css = array();
    public $data = array();
      function __construct() {
        $this->header_css[] = array('href' => '/media.css', 'media' => 'all', 'compress' => true);
        if ($this->load_main_content())
            if ($this->user_lib->getUserId() > 0)

    private function display_top_nav()
    private function display_top_menu()
    private function display_homepage()
        if ($this->user_lib->getUserId() == 0)
            $this->header_css[] = array('href' => '/login.css', 'media' => 'all', 'compress' => true);
// 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:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
&lt;title&gt;&lt;page_title />&lt;/title&gt;

&lt;header_css /&gt;



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


&lt;header_js /&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