Links and Scripts not found with CI-3

Asked

Viewed 80 times

0

I put my header and footer inside a briefcase templates which is inside the folder views, when I try to load the CSS the browser returns the erro 404 - not found, but I am 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)

Like bang inside of template I need to upload a folder ../ and then enter Assets right?

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

The file of css this inside the folder normally.

  • 1

    Placing with base_url you can access correctly?

1 answer

1


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

In other words, I define in config.php the main url of my project, and every time I upload a file, I call base_url first and then the rest of the file path. Remembering that you should configure the helper url down in the autoload.php also.

Another point is to keep your Assets files in the specific folder for them. Inside the view folder, it will only be the files of front end, as well as in models only classes and in the Controllers folder, only files with regras de negócio. I prefer to 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 that there in the config.php file is

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

When rendered in the browser, it will look like this:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.