Welcome Guest, Not a member yet? Register   Sign In
Help for accessing external css.......
#1

[eluser]raiser[/eluser]
I need to access the external css that i defined. I tried to access but i can't.. I am very new to Codeigniter. My view code is,

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;:: Registration With CI ::&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url() ?&gt;/views/css/style.css" media="screen" /&gt;
&lt;/head&gt;

&lt;body&gt;
<div class="container">
</div>

&lt;/body&gt;
&lt;/html&gt;

Then my controller is,

Code:
class Register extends CI_controller{
        function index()
        {
            $this->load->helper('html');
            $this->load->helper('url');
            $this->load->view('registration');
        }
    }

One more thing, the base_url() is ,
Code:
$config['base_url'] = 'http://localhost/CodeIgniter_2.0.1/application';

I will be very grateful to you if you solve this issue. I cannot move to the next step. So Please help me
#2

[eluser]InsiteFX[/eluser]
Also one problem may be the periods in the _2.0.1
Try this now!
Code:
// base_url should have the ending / on it
$config['base_url'] = 'http://localhost/CodeIgniter_2.0.1/application/';

// You for got the ; before the ending php tag.
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url();?&gt;views/css/style.css" media="screen" /&gt;

InsiteFX
#3

[eluser]Piter[/eluser]
See the html code which link you to generate and then you have access to this file.
#4

[eluser]raiser[/eluser]
Dear InsiteFX,

I tried your code.. But still i cant get it.. i searched the entire forum. I didnt find any thread related this. Pls help me to solve this. I cant move to the next step without this..
#5

[eluser]soupli[/eluser]
The problem must be in your config or some kind. Because i tried your code and i get the css with no problem.
Try to put all your files in another directory, like:
Code:
http://localhost/codeigniter/ci/
#6

[eluser]InsiteFX[/eluser]
Did you change your directoy name to get rid of the periods?

InsiteFX
#7

[eluser]louisl[/eluser]
I think your base url should be :-
Code:
$config['base_url'] = 'http://localhost/CodeIgniter_2.0.1/';
Then check also your css file is where you think it is by browsing to:-
Code:
http://localhost/CodeIgniter_2.0.1/application/views/css/style.css
#8

[eluser]andyy[/eluser]
Base url should match the directory where the index.php is stored and by the look of your folder names, you haven't moved anything around. Do what louisl said: set $config['base_url] to http://localhost/CodeIgniter_2.0.1/ and change your stylesheet href to application/views/css/style.css.

I recommend you create a folder in your root named something like 'assets' or 'content' and place all your css, images and javascript inside. Storing css in the application folder is unorthodox and displays your application folder path which someone could attempt to target.

I also noticed in your post, you said 'external css'. Do you mean a css file saved on your server, or another server? External usually means outside of your environment.

Also using site_url() instead can provide a cleaner looking statement:

Code:
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo site_url('views/css/style.css'); ?&gt;" media="screen" /&gt;

/* versus.. */

&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url();?&gt;views/css/style.css" media="screen" /&gt;
#9

[eluser]InsiteFX[/eluser]
He still has not done what I said!

Change the Directory name and get rid of the Periods ......

Windows may like them but CodeIgniter and Apache will not!

InsiteFX
#10

[eluser]andyy[/eluser]
@InsiteFX: That isn't the case. As proof, I just tested periods in the folder/pathname on my Windows box and my Ubuntu box both running Apache 2.2.11 with no problems...




Theme © iAndrew 2016 - Forum software by © MyBB