Welcome Guest, Not a member yet? Register   Sign In
Links and CodeIgniter? Help? [nevermind...]
#1

[eluser]Andreia M.[/eluser]
'lo, forums,

I'm new to programming in general and CI in special, as I've already mentioned. I'm having an issue, however, which is baffling...

I've a controller, main.php. In this controller I have several functions: index() loads the main page view and I have join(), which opens a form.

I've been trying to create a link in the mainview.php that would load the form in a <a href="http://www.stickmanlabs.com/lightwindow/">lightwindow</a>. Chaos ensues.

I tried to use the anchor() function from the URL helper - doesn't work. Checking the source code, it writes the link as it should - it's exactly the same as the other links, all of which work (but point to different sites or give me an expected 404 - I'm "translating" a site to CI, as to speak). It doesn't load the lightwindow or in fact does anything at all.

Code:
The anchor, straight from the view:

&lt;?php echo anchor('main/join', 'join', array('class'=>"lightwindow", 'title'=>'join', 'params'=>'lightwindow_width=516,lightwindow_height=530')); ?&gt;

The output from view >> source:
<a href="http://myurlsname.com/index.php/main/join" class="lightwindow" title="join" params="lightwindow_width=516,lightwindow_height=530">join</a>

Note that if I type the url in the browser's address, it loads.

I tried using site_url(). I tried using base_url and adding the "main/join/" bit after in pure html (I've rewrite on). Doesn't work either. I tried using current_url(). No such luck.

Code:
<a href="&lt;?php echo base_url(); ?&gt;/main/join/">...

If I write

Code:
<a href="http://myurlsname.com/index.php/main/join" class="lightwindow" title="join" params="lightwindow_width=516,lightwindow_height=530">join</a>

directly, no PHP, it works. Now, OK, I could do that, but I'd like some flexibility - not having to rewrite all the links in the site if I change the domain, for instance.

I also noticed that this

Code:
<a href="/join/">join</a>

gives inconsistent results - sometimes it tries to load http://myurlsname.com/index.php/join, sometimes it tries http://myurlsname.com/index.php/main/join (usually after I see the join page, then hit back).

Any idea(s) why? Thoughts?

EDIT: I've no idea what I did but now it works (using base_url())?!
#2

[eluser]TheFuzzy0ne[/eluser]
Your base URL should have the trailing slash on the end of it, so you don't need to prefix your path with one. However, if you want to redirect through the index.php, and don't have an htaccess file working in the background, you should be using site_url().
#3

[eluser]Andreia M.[/eluser]
[quote author="TheFuzzy0ne" date="1244334042"]Your base URL should have the trailing slash on the end of it, so you don't need to prefix your path with one. However, if you want to redirect through the index.php, and don't have an htaccess file working in the background, you should be using site_url().[/quote]
Yeah, apparently I was utterly blind to the double slashes. Now it's all fixed and working and smooth. I've the .htaccess all done and sweet and everything is working now, including lightwindow.
I still don't get the issue with using anchor though - since the output *was* correct and absolutely identical to what I wrote after, yet didn't work...




Theme © iAndrew 2016 - Forum software by © MyBB