0

I have a custom router that was built more or less using the method described in this post from Stack Overflow. It works quite well and I haven't had any problems with it until I decided that I wanted to use a variable that started with "#". Before my url structure would be:

mysite.com/gallery/variablehere

What I'm going for now is:

mysite.com/gallery/#variablehere

The problem is that magento is recognizing this as a link to an element with that ID on the page instead of that being the variable. Because of this, it routes to /gallery/index instead of the layout that I want. The function that checks for a match and sets the parameter:

public function match(Zend_Controller_Request_Http $request){
    $urlKey = trim($request->getPathInfo(), '/');
    $check = array();
    $parts = explode('/', $urlKey);
    ....
    ...
    ..
}

Doesn't even seem to get run. Does anyone know a way to get the router to recognize that as a valid variable and not just have it render the index layout automatically? Thanks for any help you might be able to give!

1 Answer 1

0

If you do not URL encode the pound signs, they don't get sent to the server. This is Url 101.

The # marks the start of the in page reference (like footnotes or pager ToC sections, marked up by <a name="footnote" />) and is if no concern to the server, since the browser can do all the work.

Some front-end Ajax frameworks have adopted this convention, but parse the browser location to adjust their behavior. At the time it was a smart idea, since it falls back gracefully, but as you see, integrating it with a server becomes a lot harder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.