Welcome Guest, Not a member yet? Register   Sign In
Accessing classes
#17

[eluser]Pascal Kriete[/eluser]
Quote:So basically what I’m trying to make is a page handler that is called at the end of a function when I want to display a page instead of $this->load->view(‘blah’);

Lots of ways to do this. You can nest views, so you could create a template view:
Code:
<html>
<?php $this->load->view('general/header'); ?>

<?php $this->load->view($content); ?>

<?php $this->load->view('general/footer'); ?>
</html>

And then all you would need to do is define a content variable that references another view:
Code:
$data['title'] = 'My great Title';
$data['animal'] = 'Pelican';

$data['content'] = 'earth/fauna';
$this->load->view('general/template', $data);

The data variables are automagically available to all nested views.

You could take it a step further and create a library that does that logic for you, So it might have a function like this:
Code:
function render($content, $data)
{
    $data['content'] = $content;
    $this->CI->load->view('general/template', $data);
}

// Used as above, but instead of data['content']
// you pass the name of the view
$this->libraryname->render('earth/fauna', $data);

Hope I understood the question correctly Wink .


Messages In This Thread
Accessing classes - by El Forum - 12-06-2008, 07:11 AM
Accessing classes - by El Forum - 12-06-2008, 09:05 AM
Accessing classes - by El Forum - 12-06-2008, 09:29 AM
Accessing classes - by El Forum - 12-06-2008, 11:49 AM
Accessing classes - by El Forum - 12-06-2008, 01:12 PM
Accessing classes - by El Forum - 12-06-2008, 04:33 PM
Accessing classes - by El Forum - 12-06-2008, 04:37 PM
Accessing classes - by El Forum - 12-06-2008, 05:08 PM
Accessing classes - by El Forum - 12-06-2008, 05:29 PM
Accessing classes - by El Forum - 12-06-2008, 05:31 PM
Accessing classes - by El Forum - 12-06-2008, 05:35 PM
Accessing classes - by El Forum - 12-06-2008, 05:40 PM
Accessing classes - by El Forum - 12-06-2008, 05:42 PM
Accessing classes - by El Forum - 12-06-2008, 05:51 PM
Accessing classes - by El Forum - 12-06-2008, 11:19 PM
Accessing classes - by El Forum - 12-07-2008, 04:49 PM
Accessing classes - by El Forum - 12-08-2008, 04:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB