Welcome Guest, Not a member yet? Register   Sign In
css / js not loadding
#1

hi,

i am new to codeignitor and i have problem

my php project structure is :

application
----controller
--------my_controller
----views
--------header
--------page1
--------page2
css
----style.css
scripts
----jsscript.js

i include style.css and jsscript in the header view

i have two method in my controller "home" and "admin"

home
--load->view(header)
--load->view(home)


admin
--load->view(header)
--load->view(admin)


in application/config/routes

"home" is my home page
$route['default_controller'] = 'my_controller/home';

and  i set this routing rule :
$route['admin'] = 'my_controller/admin';
so i want to access admin page by hand

the problem is when "my_controller/home" loads everything is good and the style.css and jsscript.js is loaded
but when i access admin they dont load

if i changed $route['default_controller'] to be
$route['default_controller'] = 'my_controller/admin';
they load

i dont know what is the problem

can any one help me
Reply
#2

The default controller can not be inside a sub-directory
What did you Try? What did you Get? What did you Expect?

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

"i include style.css and jsscript in the header view"

How the tags look like?
Reply
#4

(12-24-2017, 08:40 AM)ivantcholakov Wrote: "i include style.css and jsscript in the header view"

How the tags look like?

thanks for everyone

i figured it out

i was including them like this :
<link rel="stylesheet" type="text/css" href="css/Style.css">

but when i use :
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/Style.css">
it worked
Reply
#5

(This post was last modified: 12-24-2017, 08:59 AM by XtreemDeveloper.)

Firstly you can define base_url in config file.

$config['base_url'] = 'systemIP/CI folder name/';

After that you can load css and js file in header file using this code.
<link href="<?php echo $this->config->item('base_url'); ?>css/style.css" rel="stylesheet">

<script src="<?php echo $this->config->item('base_url'); ?>js/jsscript.js"></script>

By:Xtreem Solution

[Highly Skilled Laravel Developer](https://xtreemsolution.com/hire-laravel-developer.html)

[Dedicated PHP Developer](https://xtreemsolution.com/hire-php-developer.html)
Reply
#6

(12-24-2017, 08:57 AM)XtreemDeveloper Wrote: Firstly you can define base_url in config file.

$config['base_url'] = 'systemIP/CI folder name/';

Your value for the above is incorrect. $config['base_url']  is NOT a file path.
$config['base_url'] should be a URL complete with protocol as described in the file /application/config/config.php


Quote:/*
 |--------------------------------------------------------------------------
 | Base Site URL
 |--------------------------------------------------------------------------
 |
 | URL to your CodeIgniter root. Typically this will be your base URL,
 | WITH a trailing slash:
 |
 | http://example.com/
 |
 | WARNING: You MUST set this value!
 |
Reply




Theme © iAndrew 2016 - Forum software by © MyBB