Welcome Guest, Not a member yet? Register   Sign In
How to set a automatically base url?
#1

[eluser]UdayD[/eluser]
hi!

i just wrote a code in a view and have set a base url as below:
Code:
<base href="<?php echo "$base"; ?>">
now when i load an image in my view i have given like this

<img src="echo $base/images; /catch-me.gif" alt="catch-me"/>

but i have to write
like this
<img src="images/catch-me.gif" alt="catch-me"/>

i mean that can't it set the base url automatically like normally we do when we are developing a project.
now i have to write as
sorry to sttach the sample file because it was not getting pasted over here!
#2

[eluser]Eric Barnes[/eluser]
A base href tag ads the domain part to every link on the page. So for instance:
&lt;base href="http://yoursite.com/" /&gt;

<img src="images/test/3.gif" />
<img src="images/catch-me.gif" />
#3

[eluser]NeoArc[/eluser]
Hi (Excuse my english)

If you use the &lt;base&gt; tag, you will have to replace "<a href='#'>" with "<a href="[removed];">" in all your views Sad , because the former will not work as expected.
#4

[eluser]NeoArc[/eluser]
Hmm, forum filters...

[removed] = j a v a script : ;
without the spaces.


EDIT:
Sorry, i didn't read the topic properly...
#5

[eluser]UdayD[/eluser]
actually i think you guys not getting question.
sorry but because of forum filters i could not write my code. but will try that as below.

i have set a base url as shown previously the i wrote a image tag as below
< i m g s r c = " ? php " e c h o $ baseurl /"i m a g e s /c a t c h m e.gif" >
but cant i write like this as below
< i m g s r c = "i m a g e s /c a t c h m e.gif" >
means it will automatically take the base url, without me having to specify?
#6

[eluser]InsiteFX[/eluser]
Eric gave you the answer above!

In your config.php file autoload the url helper.

then add this between the head tags.

Code:
&lt;base href="&lt;?php echo base_url(); ?&gt;" /&gt;

This assumes that your image directory is in your root were index.php is.

And please use the CODE TAGS!

InsiteFX
#7

[eluser]UdayD[/eluser]
you mean to say that i should write the below code
Code:
$this->load->helper('url');
when i wrote above line in my config i got the error

Code:
Fatal error: Using $this when not in object context in config.php on line 2
#8

[eluser]Ivar89[/eluser]
Load it in your controller...
I just don't get why you would want you base url in an image tag...:S...
just create a map in your root called public
then create a map called images
put you pics in there and your src will be:
[code]
<i m g sr c=" /public/images/picture.jpg " />
[/code>
Maybe I misunderstood to but this would be my way...

EDITED: srry didn't see/know it would be filtered
#9

[eluser]UdayD[/eluser]
hey i cant see the code u mentioned above coz of form filters i guess.
And when
i only
give this
<img src ="image/catchme.gif">
it does not show the image
but when
i write a $base/images/catmes.gif it shows image.
i am confused what is happening
#10

[eluser]InsiteFX[/eluser]
Sorry meant to say load it in your autoload.php file in the config directory.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB