drsqpko5286 2010-12-01 06:58 采纳率: 0%
浏览 60
已采纳

codeigniter:将数据传递给视图中包含的视图

I have a controller and including two views from one function as below

$this->load->view('includes/header',$data);
$this->load->view('view_destinations',$data);

The view file view_destinations.php including a php menu file as follows

<? $this->load->view('includes/top_menu'); ?>

My question is, how can I pass data that is fetched from the controller to this included top_menu.php ?

Thank you guys

  • 写回答

5条回答 默认 最新

  • donglaoe2979 2010-12-01 07:04
    关注

    Inside your controller, have

    $data['nestedView']['otherData'] = 'testing';
    

    before your view includes.

    When you call

    $this->load->view('view_destinations',$data);
    

    the view_destinations file is going to have

    $nestedView['otherData'];
    

    Which you can at that point, pass into the nested view file.

    <? $this->load->view('includes/top_menu', $nestedView); ?>
    

    And inside your top_menu file you should have $otherData containing 'testing'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部