Welcome Guest, Not a member yet? Register   Sign In
css is not loading
#1

[eluser]mehwish[/eluser]
hi i am facing problem in loading css file.

Code:
<?php  //if ( ! defined("BASEPATH")) exit("No direct script access allowed");


class Controller2 extends CI_Controller
{


function index()
{
if ($this->input->post('button'))
$this->test();
else
$this->load->view('2');
}



function test()
{
$this->load->view('2');
}
} ?>
when i first call my controller index function it is loading view "2" with proper html and css but when i press a button inside my "2" view my controller is calling another function TEST but this time test is not loading the same view with css.

can anyone solve this?

css codeigniter
#2

[eluser]jblack199[/eluser]
are you using .htaccess to block index.php? If you are try this:
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|css|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

2nd line is where you need to add in the folders you want to grant access to. so if you have css, images, etc folders in your root folder (where they should be), adding that will make the css load.

edit:

just noticed the bottom portion of what you said, cant really help as there isnt an error in the controller. so odds are its malformed html, or a malformed url you're trying to reference. So without the code in the view, we cant really do anything for you.
#3

[eluser]mehwish[/eluser]
following is my view

Code:
&lt;!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--&gt;
<!DOCTYPE HTML>
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Rickys web templates&lt;/title&gt;
&lt;meta name="keywords" content="" /&gt;
&lt;meta name="description" content="" /&gt;
&lt;link href="style.css"  charset="utf-8" rel="stylesheet" type="text/css" media="screen" /&gt;
&lt;/head&gt;
&lt;body&gt;&lt;body>&lt;/html&gt;
#4

[eluser]jblack199[/eluser]
&lt;link href="&lt;?php echo base_url(); ?&gt;style.css" rel="stylesheet" type="text/css" media="all" /&gt;

try something like that and see if it works out better for you.
#5

[eluser]mehwish[/eluser]
also not working .. i have written the following also
Code:
&lt;?php echo base_url()?&gt;.style.css
#6

[eluser]jblack199[/eluser]
what are the differences in url's (you can use domain.com as an example like i do)? and do you have $config['base_url'] setup in your config.php?
#7

[eluser]mehwish[/eluser]
yes i have setup in cofig file
#8

[eluser]jblack199[/eluser]
and your css is in your document_root, not inside any folders right? if so,

Code:
&lt;link href="&lt;?php echo base_url();?&gt;style.css" rel="stylesheet" /&gt;
something like that should work perfectly as thats a direct snippet right from my own script and it works flawlessly. other than that, perhaps firebug can give you some insight into why its not loading on the one page, but it is on the other....

Also try getting rid of your closing ?&gt; in your controller and see if that helps any...
#9

[eluser]mehwish[/eluser]
if i am writing
Code:
&lt;?php echo base_url();?&gt;style.css
then on starting, css is lost otherwise when i was using simple
Code:
href="style.css"
on start template is loaded fine but on secons call to test function css is lost now when i am using echo base_url() the view which was loading fine is also lost
#10

[eluser]jblack199[/eluser]
check the source of the page with base_url, and ensure that its correct... if its not correct, then you've got an issue with base_url in your config.php.. but also try getting rid of the closing php tag in your controller and see if that helps.




Theme © iAndrew 2016 - Forum software by © MyBB