質問

I am working on a photography site in which I do NOT want the page got refreshed every time user goes to a new page (ie, photo) by clicking the thumbnails. At the same time, user should be able to bookmark the URL and send the links by email/chat.

So, I am using hash tags in URL, and a URL will have the format:

http://site.com/photo/#<photo_id>-<SEO>

example - http://site.com/photo/#12-blue-butterflies

I spent a lot of time writing routes, the one I finally have, which doesn't work, is:

Route::set('photo','photo(/#<id>(-<seo>))',
    array(
        'id' => '\d+',
        'seo' => '.*',
    ))
    ->defaults(array(
        'controller' => 'photo',
        'action'     => 'index',
    ));

The problem is, if I remove the hash from URL and tweek the route, I can make this work. With hash, seems impossible. I wonder if it's possible. Is it something by kohana design that we can not use # in URLs?

Thanks!

役に立ちましたか?

解決

It's not related to Kohana. # is not used in urls on the server side, period. It is never sent by the browser.

Hash tag is only available on the client side. It can be used by client-side javascript, for instance.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top