donglinyi4313 2017-04-12 13:09
浏览 70
已采纳

bootstrap不能与CodeIgniter一起使用

I have written a simple view to use bootstrap css in codeignitor.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Voyager</title>
        <link rel="stylesheet" href="<?php echo base_url("styles/bootstrap/css/bootstrap.css"); ?>" />
</head>
<body>

                <div class="panel panel-heading">
                    This is Heading
                </div>
                <input type="submit" class="btn btn-primary">

    <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo  (ENVIRONMENT === 'development') ?  'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p>
        <script type="text/javascript" src="<?php echo base_url("styles/bootstrap/js/jquery-3.2.1.min.js"); ?>"></script>
        <script type="text/javascript" src="<?php echo base_url("styles/bootstrap/js/bootstrap.js"); ?>"></script>

</body>
</html>.

Bootstrap directory is copied in root directory of project.

This is the link I followed for integration.

http://www.kodingmadesimple.com/2014/06/integrate-twitter-bootstrap3-with-codeigniter-framework.html

While running the application I get below error.

A PHP Error was encountered

Severity: Error

Message: Call to undefined function base_url()

Filename: views/view_login.php

Line Number: 10

Backtrace:

Note: If I remove bootstrap links, page is rendered without styles.

Here is the contents of autoload.php.

I have excluded commented parts in this file. I made changer to helper part as you said.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$autoload['packages'] = array();

$autoload['libraries'] = array();

$autoload['drivers'] = array();


$autoload['helper'] = array('url');

$autoload['config'] = array();

$autoload['language'] = array();

$autoload['model'] = array();

After this change new error I am getting is :

Unable to load the requested file: helpers/view_login_helper.php

  • 写回答

3条回答 默认 最新

  • duanjianxu4288 2017-04-12 13:17
    关注

    Go to your config/autoload.php and, in the helpers array do:

    $autoload['helper'] = array('url');

    That should solve the problem.

    EXTRA ADVICE: It's usually not necessary to protect a view from direct access. That's for your classes mainly. But still you can if you want to.

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料