Codeigniter未定义视图中的变量站点

时间:2015-10-13 04:31:49

标签: php html css codeigniter undefined

查看:

我运行程序时遇到错误:视图中未定义的变量站点 这是以下代码:

 <ul class="nav nav-pills">
                        <li><a href="<?php echo $site ?>/CI_timeline/index">HOME</a></li>
                  <li><a href="<?php echo $site ?>/CI_timeline/aboutus">ABOUT US</a></li>
                  <li><a href="<?php echo $site ?>/CI_timeline/services">SERVICES</a></li>
                  <li><a href="<?php echo $site ?>/CI_timeline/photogallery">PHOTO GALLERY</a></li>
                  <li><a href="<?php echo $site ?>/CI_timeline/promogallery">PROMO GALLERY</a></li>
                  <li><a href="<?php echo $site ?>/CI_timeline/contact">CONTACT</a></li>
                </ul>

此外,我在以下代码中查看了未定义变量图像中的错误:

<img src="<?php echo $base?>/<?php echo $image?>/fb.png" alt="" title="" />

我也得到了像undefined变量css,base

这样的错误
<link rel="stylesheet" href="<?= base_url() ?>assets/css/style.css" />
 <link rel="stylesheet" href="<?= base_url() ?>assets/css/bootstrap.min.css"  type="text/css" />

请为此问题提供解决方案。

2 个答案:

答案 0 :(得分:1)

因为 self.navigationController?.navigationBar.hidden = true 不包含任何值

这应该是

$site

<?php echo $site ?>

并执行此配置 (这将有助于使用<?php echo base_url() ?> 功能)

  1. base_url

    config/config.php
  2. $config['base_url'] = '';

    config/autoload.php

答案 1 :(得分:1)

class Timelinestudio extends CI_Controller{

    var $data;
     function __construct(){
        parent::__construct(); 
 //session_start();
 $this->load->model('timeline_model');
  $this->load->library('form_validation');
  $this->data = array(
        'site' => $this->config->item('site_url'),
              'base' => $this->config->item('base_url'),
              'css' => $this->config->item('css'),
              'js' => $this->config->item('js'),
     'img'=>$this->config->item('img'),
     'image'=>$this->config->item('image')
               );

               // $data = $this->data;
                //print_r($data); die();

    }

 public function index()
 {
  $this->load->helper(array('form','url'));
  $data = $this->data;
  //print_r($data); die();
  $this->load->model('timeline_model');
    $data['slideimg']=$this->timeline_model->get_slideimg();

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