http://example.com/index/index/color/red/id/230
For the above URL zend framework breaks it like the following -
module : default
controller : index
action : index
color : red
id : 230
But I want to skip the /index/index (/controller/action) part. What should I do to achieve the same result with the following URL -
http://example.com/color/red/id/230
Do I need to write a router for this? Please help me to build one. I tried the following in my routers.ini but it is now working -
routes.index.route = /
routes.index.defaults.module = default
routes.index.defaults.controller = index
routes.index.defaults.action = index
Please someone help me with this problem. Many many thanks in advance.
Yes, you'll need a route and you'll need to tell zend whats the route like. for example:
routes.index.route = "/color/:color/id/:id"
will give you something like: http://example.com/color/red/id/123
or even a bit shorter:
routes.index.route = "/color/:color/:id"
would give you http://example.com/color/red/123
your route above just points to the www root. thats why it's not working. btw. did you read this one? http://framework.zend.com/manual/en/zend.controller.router.html
Related
I want to use RealUrl extension in my typo3 site.
What I want to do:
change the usual url
"http://mysite.it/pag/index.php?id=1"
into
"http://mysite.it/pag/1"
(I wanto to hide "index.php?id=")
Is it possible to do it using RealUrl? Can someone help me? (conf example)
Thank you
In this way you probably do not need realurl.
Any url of type https://mydomain.tld/?{pageid} will be mapped by TYPO3 core to index.php?id={pageid} so you need just a small htaccess rewrite to insert the questionmark.
It is just that links are not generated in this short form. But that could be done by a lastplace replacement (do a stdWrap.replacement on the PAGEobject):
page = PAGE
page {
10 = ...
:
stdWrap.replacement {
1.search = index.php?id=
1.replace =
}
}
Your request reminds to the core-extension simulate static, but that might be obsolete and the pattern differs from your request. It was https://mydomain.tld/{pagetitle}.{pageid}[.{pagetype}].html. For the default-pagetype 0 the pagetype does not need to render.
i want to have some route for shortest url method for zend framework.
i have a router like this
http://mysite.org/en/articles/view/id/34/title/MyUniqueArticleTitleInEnglish
i can easily change to
http://mysite.org/en/viewarticle/MyUniqueArticleTitleInEnglish
i want to have something like this
http://mysite.org/MyUniqueArticleTitleInEnglish
that check if unique title not available check for 'MyUniqueArticleTitleInEnglish' controller like default route.
what must i do?
What you could do is create a routing stack that goes to the desired controller for scenario 3 if there is only one parameter in the url and goes to a 'normal' module/controller/action route if more params are supplied. Should look like:
routes.shortest.route = "/:slug"
routes.shortest.defaults.module = public
routes.shortest.defaults.controller = article
routes.shortest.defaults.action = show
routes.default.route = ":module/:controller/:action"
routes.default.defaults.controller = index
routes.default.defaults.action = index
(untested but should work)
I use modules layout to structure my controllers:
:module/:controller/:action
I would like to add a new custom route so that the following url will work.
domain.com/username
where username is a username of any registered user on the website.
Can anyone point me in the right direction?
Thank you
See this blog post for a detailed explanation of how to do this in ZF:
http://tfountain.co.uk/blog/2010/9/9/vanity-urls-zend-framework
Not sure if you can make something like domain.com/username. Instead you could do domain.com/u/username or domain.com/user/username. For example, to make the second route in you application.ini you could put something similar to the following:
resources.router.routes.user.route = "/user/:user"
resources.router.routes.user.type = "Zend_Controller_Router_Route"
resources.router.routes.user.defaults.module = default
resources.router.routes.user.defaults.controller = user
resources.router.routes.user.defaults.action = user
resources.router.routes.user.defaults.user =
resources.router.routes.user.reqs.user = "\s+"
http://framework.zend.com/manual/en/zend.controller.router.html covers quite well all the different ways you can add routes. Keep in mind, once you add custom routes, the default one will not work anymore unless you explicitly define it (as well as in url view helpers etc.).
Right now ZF defaults to /
I would really like / to redirect to /sort/all
I've changed my default route in routes.ini to
routes.default.route = "/:controller/:filter"
routes.default.defaults.controller = sort
routes.default.defaults.action = sort
routes.default.defaults.filter = all
which displays correctly but the URL doesn't change.
I don't want a user to bring up / , but i still have /contact /about so i can't just move the install path
Its probably an htaccess issue, but i didn't want to break zend default dispatching.
I would really like / to redirect to /sort/all
How about letting IndexController::indexAction() just contain:
return $this->_redirect('/sort/all');
That would be easy to maintain once you'd want to use the root uri for something else.
Because of the problems I experienced here: Zend_ Controller_ Router_Exception: “xyz” is not specified
I want to have this route:
":module/:controller/:id"
and map it onto this:
":module/:controller/:action/id/$id"
Is there any possibility to do this with Zend Framework? I do not want to forward the browser to that URL. I just want to tell Zend Framework how to handle this route.
As for reasons why I would like to do this, you can find them in that linked SO question.
Yes it is possible. In my application.ini I specify my routes using regex this way:
resources.router.routes.something.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.something.route = "mymodule/mycontroller/([0-9]+)"
resources.router.routes.something.defaults.module = "mymodule"
resources.router.routes.something.defaults.controller = "mycontroller"
resources.router.routes.something.defaults.action = "myaction"
resources.router.routes.something.map.1 = "id"
I am not familiar with the ":variable" way of defining routes, but you can take from my example the ability to set default controllers, modules, and actions, without the need to explicitly define them in the url.