CodeIgniter Forums
How to load asset [images, css, javascript] without using base_ur() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to load asset [images, css, javascript] without using base_ur() (/showthread.php?tid=36706)



How to load asset [images, css, javascript] without using base_ur() - El Forum - 12-12-2010

[eluser]himalking[/eluser]
hi guys, I have a serious problem

my application runs well, but sometimes everything gets freeze and nothing gets loaded

let me explain:
the page images, css, javascript and all paths doesn't load, though it was working well, and then I Wait for a while, and run the application again and it works again, without any change from me.

I'm setting my environment as follows:
Quote:- I moved the application folder out side system folder, in the same level as index.php
- I placed all my assets in folders [images, css, javascript] in the same level as index.php
- I use assets like this: "../images/my_image.jpg"
- I'm not using $base_url() I just place "../"

If someone can help me with this situation I will be very grateful
I also need some one to advice me the best practice to load asses(images/css/javascript)directly because I'm using a lot of images.

Excuse me for this novice question as I'm a newbie in codeigniter, I know what I'm saying is strange, may be I can't explain it well


How to load asset [images, css, javascript] without using base_ur() - El Forum - 12-12-2010

[eluser]William Lopes[/eluser]
I like to create a folder named "public" and then create a constant in the file "index.php", BASEPUBLIC (contains the path of the folder public).

To use the images, js, css.

<img src="<?=BASEPUBLIC;?>/images/teste.png"?>

Hugs.


How to load asset [images, css, javascript] without using base_ur() - El Forum - 12-12-2010

[eluser]Cesar Kohl[/eluser]
Quote:- I moved the application folder out side system folder, in the same level as index.php

WHY????????


How to load asset [images, css, javascript] without using base_ur() - El Forum - 12-12-2010

[eluser]himalking[/eluser]
[quote author="Cesar Kohl" date="1292185065"]
Quote:- I moved the application folder out side system folder, in the same level as index.php

WHY????????[/quote]

I think it's a good practice, so that when you update your codeigniter system you don't mess with your application folder


How to load asset [images, css, javascript] without using base_ur() - El Forum - 12-12-2010

[eluser]Kindari[/eluser]
I think the easiest way to do this is in your views do this:

Code:
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body><img src="images/test.jpg"></body>
</html>

By defining the base tag, all relative links are relative to that url.


How to load asset [images, css, javascript] without using base_ur() - El Forum - 12-15-2010

[eluser]himalking[/eluser]
[quote author="Kindari" date="1292204423"]I think the easiest way to do this is in your views do this:

Code:
<html>
<head>
<base href="<?php echo base_url(); ?>">
</head>
<body><img src="images/test.jpg"></body>
</html>

By defining the base tag, all relative links are relative to that url.[/quote]

the solution worked perfect for me, thanx for help :lol: