dongshuobei1037 2016-10-08 18:56
浏览 74

如何使用具有多个视图的CodeIgniter-Google-Maps-V3-API-Library?

My approach on structurizing my website is having a lot of small view files. My controllers look like this

$this->load->view('templates/header');
$this->load->view('templates/navmenu');
$this->load->view('products/create', $dat);
$this->load->view('templates/footer');

In CodeIgniter-Google-Maps-V3-API-Library examples controller passes $data variable one view file

$this->load->library('googlemaps');
$this->googlemaps->initialize();
$data['map'] = $this->googlemaps->create_map();
$this->load->view('my_view', $data);

where my_view is:

<html>
<head><?php echo $map['js']; ?></head>
<body><?php echo $map['html']; ?></body>
</html>

I have been trying to pass JS to my header view but with no success. My controller now:

$this->load->view('templates/header, $data');
$this->load->view('templates/navmenu');
$this->load->view('products/create', $data);
$this->load->view('templates/footer');

and header view file:

<html>
        <head>
                <title>CodeIgniter Tutorial</title>
                <link rel = "stylesheet" type = "text/css" href = "<?php echo base_url(); ?>css/style.css">
                <?php echo $map['js']; ?></head>
        <body>

Whatever I try to do (have spent a couple of hours) when I inspect the site I see that either JS or html part is not there.

I really liked that I had header.php view file that opened the <body> tag. It is quite easy to mix different methods on one page.

  • 写回答

2条回答 默认 最新

  • douyannuo7733 2017-01-23 12:41
    关注

    Place the below snippet in the body of the page.

    <?php echo $map['html']; ?>
    <?php echo $map['js']; ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了