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)
Related
Trying to do routing with ARCGIS SDK for ios.I have a AGSPoint with me as
AGSSpatialReference *sr = [AGSSpatialReference spatialReferenceWithWKID:102100];
AGSPoint *myMarkerPoint =[AGSPoint pointWithX:-13626235.170442
y:4549170.396625 spatialReference:sr];
I have to make AGSStopGraphic with respect to this point ,How it can be done?This is something basic ,But don't know how to do it.
And how to do routing with this?Is there a better approch
You need to create an AGStopGraphic using the AGSPoint. Your myMarkerPoint is a geometry that defines the location. Something like this:
AGSPictureMarkerSymbol* destSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImage:[UIImage imageNamed:#"RedPin.png"]];
AGSStopGraphic* stop = [AGSStopGraphic graphicWithGeometry:myMarkerPoint
symbol:destSymbol
attributes:{#"Destination" : #"Name"}];
To do the routing request, you need to start with an AGSRouteTaskParameters object and add the stops to it (along with all the other parameters) using the setStopsWithFeatures: method. Then using your AGSRouteTask object, call the method solveWithParameters: and pass it the route task parameters.
According to the AGSRouteTask documentation there is a Routing sample app that you can look at.
I'm trying to do some logic in my Spring controller where I route to a website node based on the template used in another website node.
I can use LifeTimeJCRSessionUtil.getHierarchyManager("website").getContent("mynodepath").getTemplate() to do this, but I see that the HierarchyManager and Content classes are depreciated.
I looked at the Session class, but I have thus far been unable to figure out how to get the Template id based on the jcrNode.
You can use instead:
javax.jcr.Session jcrSession = LifeTimeJCRSessionUtil.getSession("website");
Node mynode = jcrSession.getNode("/my/node/path");
info.magnolia.cms.core.MetaData metaData = info.magnolia.jcr.util.MetaDataUtil.getMetaData(mynode);
String template = metaData.getTemplate();
Basically, instead of getHierarchyManager("website").getContent("mynodepath") you should use
getSession("website").getNode("/my/node/path").
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
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.).
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.