Welcome Guest, Not a member yet? Register   Sign In
need help: css and images
#1

[eluser]j0hn[/eluser]
where can i store my css and image files in the ci directory layout? im confused a bit...
need help guys...
#2

[eluser]John_Betong[/eluser]
Hi,

There are numerous threads on where to store CSS, JavaScript, image files, etc. Try the search facility.

I prefer the CSS file to be in my application directory and use the following code.
Code:
<head>

  ...
  <base href="<?= base_url() .APPPATH ?>" />
  <link   type="text/css" href="style.css" rel="stylesheet" />
  ...

</head>
#3

[eluser]j0hn[/eluser]
i get error in base_url()...
Quote:Fatal error: Call to undefined function base_url()

every body says that the base_url should be set in config.php. but in config.php
the only base_url i found is $config['base_url'] = ""; it is not a function. even
though i used $config['base_url'] still getting error because the $config is not
set. how can i use base_url() properly?

need help....
#4

[eluser]CI Lee[/eluser]
config.php
Code:
$config['base_url']    = "http://7am.ca";

autoload.php
Code:
$autoload['helper'] = array('url');

index_view.php
Code:
<link rel="stylesheet" type="text/css" href="<?=base_url();?>/assets/css/7am.css" media="all">

That combo works for me... give it a try I suppose.

-Lee (in dire need of sleep)
#5

[eluser]ELRafael[/eluser]
or just load in your controller....

Code:
$this-load->helper('url');
#6

[eluser]CI Lee[/eluser]
I had done that before as well, however I found that I used it over and over therefor it made more sense to auto load it. And I think it equates to less typing too Big Grin


-Lee
#7

[eluser]Derek Allard[/eluser]
I'm with you Lee, I can't live without the URL helper... always gets autoloaded, along with the session library.

Quick note through about base_url, "Typically this will be your base URL, WITH a trailing slash". If you're using htaccess to rewrite, then it won't matter, but if you aren't, some of the functions may not work as expected.
#8

[eluser]ELRafael[/eluser]
depends the app.... in my case, today, i don't need to load the url function... but somecases i need!

just to show the 2 ways :-P




Theme © iAndrew 2016 - Forum software by © MyBB