• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
base_url() function to load css doesn't work

#1
[eluser]mazzy[/eluser]
I created a controller for a login page.if the login operation will go well, it will pass to index view.

Code:
if($this->form_validation->run() == FALSE)
        {
            $data['title'] = "User Access";
            $this->load->view('_login', $data);
        }
        else
        {  
            $data['title'] = " ";
            $this->load->view('/templates/index',$data);            
        }

My first question is: Why if I show the index page on the browser the url is always etc/login instead of etc/index. How can I change it?

In the index page I would load a css style but unfortunately it doens't load even if I set to autoload url helper.

Code:
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/style.css" type="text/css" />

my assets folder is in the main folder of my web app.

Code:
-Project
--application
--assets
--system
--user_guide

and
Code:
base_url()
points to Project folder. Why doesn't load correctly css style?

#2
[eluser]Aken[/eluser]
Look at your source HTML after the page loads and figure out what's wrong/missing.

#3
[eluser]mazzy[/eluser]
[quote author="Aken" date="1329093441"]Look at your source HTML after the page loads and figure out what's wrong/missing.[/quote]

I have to add all html code?

#4
[eluser]InsiteFX[/eluser]
Code:
<head>
    <base href="<?php echo base_url();?>" />
</head>

Did you add the ending slash on to your base_url ?

.htaccess
Code:
RewriteCond $1 !^(index\.php|assets|css|js|images|img|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

#5
[eluser]mazzy[/eluser]
[quote author="InsiteFX" date="1329094091"]
Code:
<head>
    <base href="<?php echo base_url();?>" />
</head>

Did you add the ending slash on to your base_url ?

[/quote]

Code:
<!DOCTYPE html>
&lt;html&gt;
&lt;head&gt;
  &lt;base href="&lt;?php echo base_url();?&gt;" /&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;title&gt;&lt;?= $title ?&gt;&lt;/title&gt;
  
  &lt;meta name="description" content="" /&gt;
  &lt;meta name="author" content="Salvatore Mazzarino" /&gt;
  
  &lt;meta name="viewport" content="width=device-width; initial-scale=1.0" /&gt;
  
  &lt;!-- jquery mobile css --&gt;
  &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /&gt;
  &lt;!-- my own style sheet --&gt;
  &lt;link rel="stylesheet" href="assets/css/style.css" type="text/css" /&gt;
  
  [removed][removed]
  [removed][removed]  
&lt;/head&gt;

Doesn't work...why?

#6
[eluser]Aken[/eluser]
[quote author="mazzy" date="1329093711"][quote author="Aken" date="1329093441"]Look at your source HTML after the page loads and figure out what's wrong/missing.[/quote]

I have to add all html code?[/quote]
Open the page in your browser. Look at the HTML source. Find where the CSS link is being generated, and look and see what is wrong with it. This is debugging 101...

#7
[eluser]InsiteFX[/eluser]
if it doe's not work then it is not finding your path!

Do what Aken told you to do...

Also shop how you have your base_url set in config.

#8
[eluser]mazzy[/eluser]
[quote author="Aken" date="1329094485"][quote author="mazzy" date="1329093711"][quote author="Aken" date="1329093441"]Look at your source HTML after the page loads and figure out what's wrong/missing.[/quote]

I have to add all html code?[/quote]
Open the page in your browser. Look at the HTML source. Find where the CSS link is being generated, and look and see what is wrong with it. This is debugging 101...[/quote]

well simple to do but it happens strange thing. if I open view code in index page I obtain the header of login page where there is not style css loader

#9
[eluser]InsiteFX[/eluser]
Then you need to add a header to that

#10
[eluser]mazzy[/eluser]
[quote author="InsiteFX" date="1329094832"]Then you need to add a header to that
[/quote]

but is it normal I obtain this behavior?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.