drsqpko5286 2010-12-01 14: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 15: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条)

报告相同问题?

悬赏问题

  • ¥20 关于#深度学习#的问题:2708)输出:邻接矩阵A 或者 节点索引方式:通过随机游走或者其他方式,保持节点连接类似下图(语言-python)
  • ¥15 win11 24h2 右键打印怎样删除
  • ¥15 win2012 iscsi ipsec
  • ¥15 封装的 matplotlib animation 不显示图像
  • ¥15 python摄像头画面无法显示
  • ¥15 关于#3d#的问题:d标定算法(语言-python)
  • ¥15 cve,cnnvd漏洞扫描工具推荐
  • ¥15 图像超分real-esrgan网络自己训练模型遇到问题
  • ¥15 如何构建全国统一的物流管理平台?
  • ¥100 ijkplayer使用AndroidStudio/CMake编译,如何支持 rtsp 直播流?