CodeIgniter Forums
anchor function for in page links - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: anchor function for in page links (/showthread.php?tid=32903)



anchor function for in page links - El Forum - 08-09-2010

[eluser]vertmonkee[/eluser]
At the top of my page I will have links to jump to different id's within the same page like this
Code:
<a href="#id-1">First section</a>
<a href="#id-2">Second section</a>
<a href="#id-3">Third section</a>

If I use the anchor function from codeigniter like this

Code:
&lt;?php echo anchor('#id-1', 'First section'); ?&gt;

It creates a link to the full url where as I just want it to move the page down to that id.

If I just put the regular <a> tag in it works fine.

Is there a way to do this with codeigniter or should I just stick with the HTML tags?

Thanks


anchor function for in page links - El Forum - 08-09-2010

[eluser]Maglok[/eluser]
The strength of the CI anchor() method lies in that it is based on the concept of in-CI urls. Something you cannot do with plain html as easily. Since you are making an internal link on the same page you can just reference PHP_SELF or even just <a href="#id-1">.

That said I don't use anchor all that much myself. Not a big fan of internal links. Smile