3

I am currently trying to load a css file into a CodeIgniter view in the follow manner:

<link rel="stylesheet" href="<?php echo base_url(); ?>css/style.css">

A blank page is loaded. It seems that when I call the base_url function in the view the page doesn't load because the same thing happens when I call base_url() else where in the view but the page actually loads without css when I remove the calls to that function. Is there something that I need to require in order for the page to load?

3
  • Have you actually loaded the URL helper in your controller, via $this->load->helper('url') ?? Also, a blank page usually means a fatal error, but you have error displaying turned off. Google it. Commented Jul 10, 2013 at 7:05
  • what is the value of <?php echo base_url(); ?>. what is the absolute path to css file. alternatively you can try file bug toll by given the suggested path and monitor if it loading at real-time Commented Jul 10, 2013 at 7:13
  • loading the url helper fixed the problem. thanks Commented Jul 10, 2013 at 7:17

3 Answers 3

1

From: http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

This helper is loaded using the following code:

$this->load->helper('url');

The following functions are available:

...

You need to first load the helper either in the method called, or in the class constructor.

Sign up to request clarification or add additional context in comments.

Comments

0

Try import annotation.

<style> @import url('<echo base_url()?>/css/styles.css'); </style>

Comments

0

You could do like this:

<link href="<?php echo base_url('assets/css/bootstrap.min.css') ?>" rel="stylesheet">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.