Hash: SHA1
Dimitri van Hees wrote:
> Hmm, I've got the following route now:
>
> page.type = "Zend_Controller_Router_Route_Regex"
> page.route = "page(\/.*)"
> page.map.1 = "path"
> page.reverse = "%s"
> page.defaults.controller = "page"
> page.defaults.action = "index"
>
> This means that site.com/page/hello/world returns $path = '/hello/word'
> which is what I expected.
>
> However, there seems to be something wrong with the reverse function.
>
> $this->url(array('path' => '/hello/world'), 'page') doesn't return
> '/page/hello/world' but just '/hello/world'.
>
> Is this behaviour correct and if so, why?
This is correct, because you have your page.reverse set to %s - which
will just be substituted for the parameter you give it. Change it to:
page.reverse = "page%s"
This does assume you'll always pass an "absolute" (starting with "/")
path as the "path" parameter. Personally, I'd probably make it:
page.reverse = "page/%s"
and always pass a path without the leading "/". But that might depend on
your implementation.
- --
Brenton Alker
PHP Developer - Brisbane, Australia
http://blog.tekerson.com/
http://twitter.com/tekerson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkrJt3kACgkQ7bkAtAithuty3gCfXpCWnVqNewCDD+DzZmwf5SsC
IOQAoMtCiExc7/dH7sjx5nNj+gUL1yXL
=FP/7
-----END PGP SIGNATURE-----
没有评论:
发表评论