CodeIgniter Forums

Full Version: css are not loading
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

I wonder why the css files are not loading?


views/index.php

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


config.php

       $config['base_url'] = 'http://localhost/coolcicms/';


File location:

coolcicms/assets/css/style.css
coolcicms/assets/css/custom.css

I already autoload the url helpder.
Right click -> View source
(05-05-2018, 06:40 AM)jreklund Wrote: [ -> ]Right click -> View source

F12 and the network tab Smile
In the Network Tab

Request URL:
http://localhost/coolcicms/index.php/<? echo base_url('assets/css/style.css'); ?>
Request Method:
GET
I think I am going to post the solution that I discovered.

<?php echo base_url('assets/css/style.css'); ?>
(05-05-2018, 06:30 AM)davy_yg Wrote: [ -> ]Hello,

I wonder why the css files are not loading?


views/index.php

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


config.php

       $config['base_url'] = 'http://localhost/coolcicms/';


File location:

coolcicms/assets/css/style.css
coolcicms/assets/css/custom.css

I already autoload the url helpder.

Use this:
<link rel="stylesheet" href="<?= echo base_url('assets/css/style.css'); ?>">
<link rel="stylesheet" href="<?= echo base_url('assets/css/custom.css'); ?>">

"<?" does not mean "echo" or "print" but "<?=" does
@BobM: Now you got double echo. <?= echo means <?php echo echo.

<? are shorthand for <?php if you have activated it. So it works on some systems.
"<? are shorthand for <?php if you have activated it. "

How to activated it?
It should be like this:

PHP Code:
<link rel="stylesheet" href="<?= base_url('assets/css/style.css'); ?>"

And this is why they say do not use SHORT OPEN TAGS...
Guys I'm having the same problem.

My code in my view file.
<link rel="stylesheet" href="<?= base_url('bootstrap/css/bootstrap.min.css'); ?>" type="text/css">

The bootstrap assets are in a folder called bootstrap at the same level as the application folder.

/path/to/web/root/
├── application/
└── views/
├── templates
├── header.php
├── footer.php
├── system/
├── bootstrap/

rendered output
<link rel="stylesheet" href="http://localhost/codeigniter/bootstrap/css/bootstrap.min.css" type="text/css">

I've tried different locations within the project, nesting it in the application folder and under views but with the same non result even thought the path always seems to correct in relation to the local folder structure. Trying to access the css files directly through the browser generates a 404?

If I link to external css files they load fine.

What esoteric thing could be going on here? I've spent a nearly a day on this and its driving me insane.

I've got myself ready for a massive face palm.

TIA
Pages: 1 2