Welcome Guest, Not a member yet? Register   Sign In
Can't get the path to my css file.
#1

[eluser]chefnelone[/eluser]
Hi,

I have this line to get a css file in views/includes/header.php:

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

As far as I know that should work fine since I have this line in config/config.php

$config['base_url'] = "http://locallhost/ci/";


But 'echo base_url();' doesn't print the path.


What am I doing wrong?
#2

[eluser]jedd[/eluser]
Quote:<link rel="stylesheet" href="<?php echo base_url();?>/css/style.css" type="text/css" media="screen" />

Try using the [url="/user_guide/helpers/html_helper.html#link_tag"]link_tag()[/url] function instead.
#3

[eluser]chefnelone[/eluser]
tried, but still not working

It seems like I can't get base_url() nor link_tag() from header.php

I guess I'm loading header.php in wrong way. This is what I did (and all I did):

I have this line to get a css file in views/includes/header.php:
<link rel=“stylesheet” href=”<?php echo base_url();?>/css/style.css” type=“text/css” media=“screen” />

then, header.php is loaded within:
views/index.php

whith:
<?php $this->load->view('includes/header'); ?>

and first of all, this is the controller loading .../views/index.php:
class Welcome extends Controller {

function Welcome()
{
parent::Controller();
}

function index()
{
$this->load->view('index');
}
}
#4

[eluser]jedd[/eluser]
Quote:It seems like I can't get base_url() nor link_tag() from header.php

link_tag requires the html helper, of course, to be loaded. Set it in config/autoload.php if you haven't already.

Use code tags around your code - it's much easier to read.

Code:
<link rel=“stylesheet” href=”<?php echo base_url();?>/css/style.css” type=“text/css” media=“screen” />

base_url contains a trailing slash, so you don't need the / before 'css/style' there.

What does the page-source show you when you load this page? Can you open up the CSS that is pathed in that page source? You will have to do some basic trouble-shooting at your end first to identify the nature of the problem.
#5

[eluser]chefnelone[/eluser]
Yes I can access the css file.

I'm starting my site from scratch, then I have nothing in my views/index.php yet.

Above I posted the basic structure I have until now.

[quote author="jedd" date="1260036423"] You will have to do some basic trouble-shooting at your end first to identify the nature of the problem.[/quote]
This is what I'll do.


Just to be sure: the only stated line I need to get 'base_url()' in any of my views is:

Code:
$config['base_url']    = "http://locallhost/ci/"; //in config/config.php

or, do I need to state something else?

thanks
#6

[eluser]jedd[/eluser]
Quote:or, do I need to state something else?

Yup - that's pretty much it.

Complications beyond that can arise from the presence and content of an .htaccess file, whether you're removing index.php (also in config.php), and possibly the uri protocol choice (again, config.php).
#7

[eluser]chefnelone[/eluser]
Fixed! Thanks




Theme © iAndrew 2016 - Forum software by © MyBB