Welcome Guest, Not a member yet? Register   Sign In
How to load asset [images, css, javascript] without using base_ur()
#1

[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
#2

[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.
#3

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

WHY????????
#4

[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
#5

[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.
#6

[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:




Theme © iAndrew 2016 - Forum software by © MyBB