Welcome Guest, Not a member yet? Register   Sign In
wrong image and css files paths in view files
#11

[eluser]cb951303[/eluser]
[quote author="Sumon" date="1220803807"]I am not sure my approach is standard or not. But i use it without getting any trouble.
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 content="text/html; charset=UTF-8" http-equiv="content-type" /&gt;
        &lt;title&gt;Test&lt;/title&gt;
        &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url();?&gt;test.css" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <img src="&lt;?php echo base_url();?&gt;images/logo.png" alt="LOGO" />
    &lt;/body&gt;
&lt;/html&gt;

Only add base url before any css or image location. this produce absolute path and doesn't create any problem for me.[/quote]

that's the one I was looking for Smile doest it have any disadvantage over the complex one?
#12

[eluser]esra[/eluser]
The complex one is based on the same approach. The complex one appends fragments of various urls to the base_url config parameter.
#13

[eluser]phantom-a[/eluser]
I had this problem too. Confusedhut:
It tries loading images and css from http://example.com/index.php/controller/images/

but does not exist, Then I use baseurl as others said here.
#14

[eluser]cb951303[/eluser]
uhmm... sory for being noob but there is no function called "base_url()"? is it a CI function or core PHP?
#15

[eluser]Pascal Kriete[/eluser]
It's a function of the URL helper (a good one to autoload).
#16

[eluser]cb951303[/eluser]
[quote author="inparo" date="1220813274"]It's a function of the URL helper (a good one to autoload).[/quote]thanks
everything works perfectly now Smile
#17

[eluser]Tanque[/eluser]
as Sumon said... just need base_url() before the url to get your files... ci it's strange about this, but this way should work perfectly... i had the same problem last week... don't get scare... it's just that, base_url()...
#18

[eluser]jackbenning[/eluser]
&lt;?php echo base_url();?&gt;images/myimage.png
&lt;?php echo base_url();?&gt;css/mycss.css
&lt;?php echo base_url();?&gt;js/myjs.js

FTW
#19

[eluser]Dave Rau[/eluser]
How do you use base_url() in a php header file being included that's outside of the CI tree?
#20

[eluser]Colin Williams[/eluser]
CI trees are magnificent. I grew one outside my office.

Incredible how complex this stuff is made to be... Confusedmirk:




Theme © iAndrew 2016 - Forum software by © MyBB