Problem with Links. |
[eluser]emcgfx[/eluser]
My link keeps repeating it self some times when I click on it. What I mean is it should be http://localhost/ci/site/blog but when I click on the link it always just repeats it by adding one more /blog, so if I would click five times it would make this link > http://localhost/ci/site/blog/blog/blog/blog/blog/ Instead it should of just go to my "blog" controller. But this not happens every time, only some times. I can't seem to figure out what is the problem. The only thing I could think of is that I've added pagination to my script and this is what happens now.
[eluser]rampelli[/eluser]
i think you are new to CI .. You should use anchor() function for links or you should provide the full path of the link using base_url() function which is an CI function
[eluser]emcgfx[/eluser]
Thanks rampelli, I've actually tried base_url() after I posted this and it worked just fine No more errors so far.
[eluser]davidbehler[/eluser]
base_url only works if you are not using index.php. Try using site_url() instead, it provides the same as base_url but includes the index.php if it's needed and it even accepts arguments: Code: // base_url: I usually use anchor() or site_url() to generate links/urls that point to my controllers/functions and base_url() when generating urls to images, js files and so that are not in the application folder, e.g. Code: <img src="<?php echo base_url().'images/test/test.png'; ?>" />
[eluser]khagendra[/eluser]
Try like one of these 1. site_url('controlloerName') if u want to invoke the default function index(). 2. site_url('controlloerName/functionName') if u want to invoke the some function 3. site_url('controlloerName/functionName/parameter1') if u want to invoke the some function with one parameter 4. site_url('controlloerName/functionName/parameter1/parameter2') if u want to invoke the some function with two parameters ----similarly for any no of parameters Hope this will help u. |
Welcome Guest, Not a member yet? Register Sign In |