我想一些数据传递给我的侧边栏,但我不知道如何做到这一点的最佳实践,笨栏问题
我有一个模板文件是这样的:
<?php
$this->load->view('include/header');
$this->load->view($main_content);
$this->load->view('include/footer');
?>
我造一个配偶帮助文件像这样:
<?php
//Getting all the Reviews and put them on the includes/header.php
function sidebar()
{
//Get the instance of the framework
$CI=& get_instance();
//Getting data from sidebarModel
$CI->load->model('sidebar_model');
$sidebarData = $CI->sidebar_model->getSidebarReviews();
return $sidebarData;
}
,然后我想我需要去我的header.php文件,并做一些那里得到的数据输出在foreach,但我不知道怎么办。
希望有人能帮助我
问候辛
是这样的? http://pastebin.com/npnRKqf2 echo $ sidebarRow;它说Undefined变量:sidebarRow – Sim
嗯,我不能得到它的工作:( – Sim
首先,'$ this'在Helper中不起作用,那么我已经编辑了答案。 – Usman