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条)

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号