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']; ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程