How to create a default css file for CI? |
[eluser]Shaheer[/eluser]
Hello, this is my first day at CI. i was creating a sample page and i succeed. But when i tried to add a css file it failed. I put the same css file in Views folder and System and main htdocs but it just didn't got attached. Can any one help? Sorry for my English
[eluser]tomcode[/eluser]
Welcome to CI . Using CI You should always use absolute URL's for assets( CSS, images, links), since depending on Your controller the page URL changes. There are several possibilities, read the user guide. In Your case use base_url() from either the url helper or the config class.
[eluser]Shaheer[/eluser]
thanks for reply. can you post the link to that page of user guide. i haven't covered CI completely yet i am using a book. so i didn't yet understand about that base_url thing. Please help.
[eluser]tomcode[/eluser]
http://ellislab.com/codeigniter/user-gui...elper.html http://ellislab.com/codeigniter/user-gui...onfig.html, fetching config items
[eluser]Slowcheetah[/eluser]
i use Code: <link href= "<?php echo base_url(); ?>assets/css/master.css" rel="stylesheet" type="text/css" /> And place my css: codigniter_installation/assets/css/master.css
[eluser]tomcode[/eluser]
Where do You have You index.php ? webroot/index.php webroot/codigniter_installation/index.php The base_url always starts where Your index.php is.
[eluser]Shaheer[/eluser]
it still doesn't work i have placed the style.css file in the same folder as index.php but no changes below is the view file <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <link rel="stylesheet" href="<?php echo base_url(); ?>style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Web Test Site</title> </head> <body> <h1><?php echo $mytitle; ?></h1> <p class="test"> <?php echo $mytext; ?> </p> <?php echo $base ?> </body> </html> $base and other vars are passed by control.
[eluser]Slowcheetah[/eluser]
What output has the folowing code? Code: <?php echo base_url(); ?>
[eluser]Shaheer[/eluser]
first it was http://www.example.com/ then i modified it to http://localhost. is the problem with that? |
Welcome Guest, Not a member yet? Register Sign In |