Welcome Guest, Not a member yet? Register   Sign In
Problem with routing and accessing anchored text
#1

[eluser]Unknown[/eluser]
I have a small problem. I have a link in my view that looks something like this:

Code:
<href="&lt;?php echo site_url(strtolower('horse-wiki/'.$letter.'/#'.$wiki->title)); ?&gt;">

Problem occurs when routing this to the controller and its function. It appears that the problem lies in the '#' character, since the routing works perfectly fine when i make the link without the anchor. This is the route I'm trying to use but is not working:

Code:
$route['horse-wiki/([a-z])/#([a-z]+)'] = "wiki/singlewiki/$1";

I'm guessing that my regular expression for the second part of the URL where the '#' is located isn't quite correct.
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums.

You're missing a "+". Smile

At the moment, the route only matches a single character after "horse-wiki/".

Code:
$route['horse-wiki/([a-z]+)/#([a-z]+)'] = "wiki/singlewiki/$1";

I'm not sure that that will do it, however. I think it would need to be more like this:
Code:
$route['horse-wiki/([a-z]+)/#([a-z]+)'] = "wiki/singlewiki/$1/$2";

Hopefully, that should do what you want.

All the best.
#3

[eluser]Unknown[/eluser]
There is only character after "horse-wiki" so I didn't put the "+".

I've tried all combination and variations for the regular expression, including the ones you provided but with no luck.

If don't try to route and make links look like controller/function/argument everything works perfectly fine so the problem lies only in routing and the actual anchor links.




Theme © iAndrew 2016 - Forum software by © MyBB