View loses the path as the case of the controller call - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: View loses the path as the case of the controller call (/showthread.php?tid=61277) |
View loses the path as the case of the controller call - smallbug - 04-06-2015 Hi All! I'm using the controller: PHP Code: public function test() { to call the view-page "messages_view.php", which shows a picture: Code: <!DOCTYPE html> By sending: http://localhost/testproject/index.php/employee/test/ It works fine! But if I have transfer parameters like: PHP Code: public function test($var1, $var2) { By sending: http://localhost/testproject/index.php/employee/test/1/2 the messages_view.php loses the path to the picture! It seems that the deep of the path depends on the amount of the called transfer parameters. How could I resolve this situation? RE: View loses the path as the case of the controller call - CroNiX - 04-06-2015 Don't use a relative path, with "../.." stuff. That means it's looking down from the 2 dirs from the CURRENT url, so if you have more parameters in the url it looks in the wrong location! Load the url helper (autoload) and use base_url(), like: PHP Code: <img src="<?php echo base_url('image/app/mypic.jpg'); ?>" /> will produce http://yoursite.com/image/app/mypic.jpg for the image src RE: View loses the path as the case of the controller call - smallbug - 04-06-2015 Thanks a lot! That's what I am looking for! |