控制器
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends CI_Controller
{
public function index()
{
$this->load->model('Event');
$todays_events = $this->Event->get_todays_events();
$data = array(
'todays_events' => $todays_events
);
$this->load->view('main/index', $data);
}
}
?>
主/索引视图
<?php $this->load->view('partial/header'); ?>
<?php $this->load->view('components/calendar/mon_to_wed'); ?>
<?php $this->load->view('partial/footer'); ?>
组件/日历/mon_to_wed
(可以访问 $todays_events,这是为什么呢?)
<div id="calendar_today">
<h1>Whats Happening</h1>
<?php foreach($todays_events as $event) : ?>
<?php var_dump($event); ?>
<?php endforeach; ?>
</div>