All pastes #798639 Raw Edit

Untitled

public text v1 · immutable
#798639 ·published 2007-11-26 22:34 UTC
rendered paste body
hmvc_helper.php:

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* load_view
*
* Loads a view from a library
*
* @access    public
* @param    string
* @return    string
*/
// hmvc view loader helper
function load_view($controller_library_name)
{
   $CI =& get_instance();

   // strip off the .php file extension if added
   $file_name = str_replace(EXT, '', $controller_library_name);
   $file_name = strtolower($file_name);

   // load the library
   $CI->load->library($file_name);
   // call a default index() method which returns a partial view with data using $CI->load->view('view_name',$data,true);
   return $CI->$file_name->index();
}

?>

------------------------------------------
Header.php (library)

<?php

class Header  {

	function __construct()
	{
	}

    function index()
    {

        $CI =& get_instance();
		$CI->load->model('Nieuws_model');
		$data['nieuws'] =  $CI->Nieuws_model->get_last_two_entries();
        $CI->load->view('global/header', $data);
    }
}

?>

front.php (front controller)
<?php

class Front extends Controller {

	function __construct()
	{
		parent::Controller();

		$this->load->helper('url');
		$this->load->helper('html');
		$this->load->helper('hmvc');


	}

	function index()
	{
		$data['title'] = 'JJB IT Service: Webhosting, onderscheid door kwaliteit!';
		$this->load->view('index',$data);
	}
}
?>

--------------------
index.php <view>

<?=load_view('Header')?>

		<div id="box_center">
			<div class="cssbox center">
				<div class="cssbox_head">

<cut>