Welcome Guest, Not a member yet? Register   Sign In
Weird behavior with segments
#1

[eluser]spyro[/eluser]
I am working on a controller that is used in an email confirmation. The email is a link that contains the id of the confirmation record. What happens is that I take the segments and parse them to execute the email confirmation. When the link is first called and processed by the controller the email is confirmed. The weird behavior is that after the first round the page tries to load a few images in the view. Each of those image loads also somehow get routed through the same controller. In firebug I can see that images are trying to load from a new_images folder. This folder doesn't exist and I also searched the code for new_images and it came up empty. Any ideas on what could be happening?
#2

[eluser]TheFuzzy0ne[/eluser]
Sounds like you are calling your images with a relative path, and not an absolute path.

If you prefix your image src attribute with a forward slash, it should start working.

Code:
<img src="/images/some_image.gif" alt="Some image" />

Alternatively, you can use base_url() to generate an absolute URL for your images.

Code:
&lt;img src="&lt;?php echo base_url() . 'images/some_image.gif'); ?&gt;" alt="Some image" />

But you will need to have loaded the URL helper:
Code:
$this->load->helper('url');

The second method is probably the best route to take.
#3

[eluser]xwero[/eluser]
TheFuzzy0ne it's best to use base_url because site_url can generate full urls like this : http://site.com/index.php/images/some_image.gif. This depends on whether the index_page setting has an empty string or not.
#4

[eluser]TheFuzzy0ne[/eluser]
My bad. I've changed the information. to reflect that. Thanks for pointing it out.




Theme © iAndrew 2016 - Forum software by © MyBB