Links and Scripts not found with CI-3

0

I put my header and footer inside a templates folder that is inside the views folder, when I try to load the CSS the browser returns erro 404 - not found , but I'm following according to what the IDE shows to have no error.

Below the folder structure.

Views
assets
   css
   js
   image
   font
   font_awesome
errors
template
   header
   footer
painel_view.php (pagina index)

How did you break into template I need to upload a ../ folder and then get into assets right?

<link rel="stylesheet" type="text/css" href="../assets/css/bootstrap.min.css">

The file of css is inside the folder normally.

    
asked by anonymous 10.09.2015 / 21:08

1 answer

1

I always work with base_url() , you can check the documentation on the link

That is, I define the main url in my project in config.php, and each time I load a file, I first call base_url and then the rest of the file path. Remember that you should set the helper url there in autoload.php too.

Another point is to keep your assets files in the specific folder for them. Within the view folder, only the front end files, as well as in models only classes and in the Controllers folder, only files with regras de negócio . I'd rather use the files as follows:

Raiz do Projeto: (www.site.com.br)
    assets
       css
       js
       imagens
    application
       (todos os diretórios do framework)

In your case, it would look something like this:

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

Following the logic there in the config.php file is

config['base_url'] = 'http://www.site.com.br'; 

When rendered in the browser, it looks like this:

<link rel="stylesheet" type="text/css" href="http://www.site.com.br/assets/css/bootstrap.min.css">
    
28.09.2015 / 15:57