How to set a automatically base url? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to set a automatically base url? (/showthread.php?tid=31393) |
How to set a automatically base url? - El Forum - 06-17-2010 [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"; ?>"> <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! How to set a automatically base url? - El Forum - 06-17-2010 [eluser]Eric Barnes[/eluser] A base href tag ads the domain part to every link on the page. So for instance: <base href="http://yoursite.com/" /> <img src="images/test/3.gif" /> <img src="images/catch-me.gif" /> How to set a automatically base url? - El Forum - 06-17-2010 [eluser]NeoArc[/eluser] Hi (Excuse my english) If you use the <base> tag, you will have to replace "<a href='#'>" with "<a href="[removed];">" in all your views , because the former will not work as expected. How to set a automatically base url? - El Forum - 06-17-2010 [eluser]NeoArc[/eluser] Hmm, forum filters... [removed] = j a v a script : ; without the spaces. EDIT: Sorry, i didn't read the topic properly... How to set a automatically base url? - El Forum - 06-17-2010 [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? How to set a automatically base url? - El Forum - 06-18-2010 [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: <base href="<?php echo base_url(); ?>" /> This assumes that your image directory is in your root were index.php is. And please use the CODE TAGS! InsiteFX How to set a automatically base url? - El Forum - 06-18-2010 [eluser]UdayD[/eluser] you mean to say that i should write the below code Code: $this->load->helper('url'); Code: Fatal error: Using $this when not in object context in config.php on line 2 How to set a automatically base url? - El Forum - 06-18-2010 [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 How to set a automatically base url? - El Forum - 06-18-2010 [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 How to set a automatically base url? - El Forum - 06-18-2010 [eluser]InsiteFX[/eluser] Sorry meant to say load it in your autoload.php file in the config directory. InsiteFX |