Welcome Guest, Not a member yet? Register   Sign In
Route to named anchor - #anchor - is it possible?
#1

[eluser]Flemming[/eluser]
this may be a ridiculous question but is it possible to use routes with named anchors?

I have a really long page in my project with named anchors, and a 'jump to' menu at the top of the page.

I'm also linking to these named anchors from my footer file (on every page) like so:

Code:
<a href="/services#advertising">advertising</a>
<a href="/services#brand">brand</a>
and so on.

From my footer it would be great if I could link to :
Code:
<a href="/services/advertising">advertising</a>

and reroute these to the named anchors. In routes.php I tried
Code:
$route['services/advertising'] = "services#advertising";

but I just get a 404.
#2

[eluser]pkrstic[/eluser]
Named anchors cannot be transfered to php, one solution is to save them in cookie with javascript and then jump to link. If you don't use ajax on front then avoid named anchors.
#3

[eluser]pickupman[/eluser]
Instead of using routes what happens when use a rule htaccess instead. You may have to craft you regex to make it work.
#4

[eluser]jmadsen[/eluser]
you might try also making your anchor tags "false" and having js handle the click with a [removed].

You can write that with a single class name and generic js function that could be used throughout your site.
#5

[eluser]Fireclave[/eluser]
you could use the third parameter for this problem

$route['controller/method/([a-z]+)'] and the third could be the anchor

take a look here http://ellislab.com/codeigniter/user-gui...uting.html




Theme © iAndrew 2016 - Forum software by © MyBB