Welcome Guest, Not a member yet? Register   Sign In
css are not loading
#1

(This post was last modified: 05-15-2018, 07:31 PM by davy_yg.)

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.
" If I looks more intelligence please increase my reputation."
Reply
#2

Right click -> View source
Reply
#3

(05-05-2018, 06:40 AM)jreklund Wrote: Right click -> View source

F12 and the network tab Smile
Reply
#4

In the Network Tab

Request URL:
http://localhost/coolcicms/index.php/<? echo base_url('assets/css/style.css'); ?>
Request Method:
GET
" If I looks more intelligence please increase my reputation."
Reply
#5

I think I am going to post the solution that I discovered.

<?php echo base_url('assets/css/style.css'); ?>
" If I looks more intelligence please increase my reputation."
Reply
#6

(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
Reply
#7

@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.
Reply
#8

"<? are shorthand for <?php if you have activated it. "

How to activated it?
" If I looks more intelligence please increase my reputation."
Reply
#9

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...
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB