Welcome Guest, Not a member yet? Register   Sign In
Best way to avoid duplicating html in views
#22

[eluser]mortifrog[/eluser]
ok one last quick reply then off to the land of nod.

Quote:Every Controller is also available over the url
- yes but you can make all of it's functions private by prefixing them with a double underscore can you not?

I can envisage wanting to borrow the logic of one controller within another - but I take on board what your saying about hooks and helpers and stuff. I've not really got that far yet.

I did try this though:

Code:
class Quatermass extends Controller {

    function Quatermass()
    {
        parent::Controller();    
    }
    
    function index()
    {    
    
    include('./system/application/controllers/quatermass2.php');
    $q2= new Quatermass2;
    
    $data['site_name'] = 'Quatermass';
    $data['template'] = 'default';
    $data['content'] = $this->load->view('view_a');
    $data['content'] .= $this->load->view('view_b');
    $data['content'] .= $q2->wow();
    $this->load->view('templates/default/index', $data);
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
?>

Code:
<?php

class Quatermass2 extends Controller {
    
    function Quatermass2()
    {
        parent::Controller();    
    }
    
    function wow()
    {    
    $wow = 'Wow!';
    return $wow;
    }
    
}


?>

And it worked, which is pretty useful to know as long as it's not a bad habit to get into.
Don't know why the output returns Wow on a new line though. Goodnight all.


Messages In This Thread
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:50 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 09:31 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:24 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:35 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:46 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 01:10 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 01:27 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 05:44 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:24 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:24 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:54 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:04 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:13 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:18 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:19 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:26 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:27 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:29 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:30 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:32 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:42 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 09:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB