Welcome Guest, Not a member yet? Register   Sign In
Directory navigation
#1

Hello there and nice to meet you. I am a new CI member and my name is Jose.

I have the next directory structure inside my root folder:

-> assets
|-->css
|-->bootstrap.min.css
-> secured_folder
|--->secured_application_folder
|--->cache
|--->config
|--->...
|--->views
|---> index.php
|--->secured_system_folder

To reference the css code from inside the index.php view file (located at /secured_folder/secured_application_folder/views) I need to just go up one level, like this:

Code:
<link href="../assets/css/bootstrap.min.css" rel="stylesheet">

Apparently this is not true, I would have to go up three levels: from "views" folder to "secured_application_folder"; from "secured_application_folder" to "secured_folder", and from "secured_folder" to my root folder.

This code won't work, though:

Code:
<link href="../../../assets/css/bootstrap.min.css" rel="stylesheet">

Why is this happening? Huh

Thanks!
Reply
#2

try making your link tag look like this:

Code:
<link href="<?php echo base_url(); ?>assets/css/bootstrap.min.css" rel="stylesheet">
"I reject your reality and substitute my own" - Adam Savage, M5 Inc.
Reply
#3

Thanks Hobbes for your answer. I tried it but now nothing appears in my webpage (like if the <body> tag were not rendering its contents properly)

Why is that? I just replaced this line:

Code:
<link href="../assets/css/bootstrap.min.css" rel="stylesheet">

With this one:

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

The complete index.php file looks like:

PHP Code:
<!DOCTYPE html>
<
html lang="en">
    <
head>
        <
title><?php echo $title ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        
        <!-- Bootstrap core CSS -->
        <link href="../assets/css/bootstrap.min.css" rel="stylesheet">
        
    </head>
    
    <body>
        <div class="container">
            <h3>Hello! This is some text inside the "container" class.</h3>
            <div class="row">
                <div class="col-md-8">.col-md-8</div>
                <div class="col-md-4">.col-md-4</div>
            </div>
        </div>
    </body>

</html> 

I must remark anyway that, using the first line of code I stated in this answer, the page will load successfully with the .css file properly loaded. The thing is that I don't know why I just have to go up 1 level (i.e. why I have to use ../ once) instead of 3 times.

Thanks in advance for your help.
Reply
#4

You have to place your assets folder directly under the root

Code:
/application
/system
/...
/assets/

Then you can acces your assets with a url like "/assets/..."

Reply




Theme © iAndrew 2016 - Forum software by © MyBB