url - zend framework get id in /delete/2 -
i'm using zend, , wonder how id in such url :
/delete/2
i know can using :
// if url /delete/id/2 $request->getparam('id');
but want have url first 1 /delete/2
sounds more logical me.
ideas?
thanks help
i think should able solve kind of problem using routes. can create route for
/delete/2
by adding example config.ini
file:
[production] routes.delete.route = "delete/:id" routes.delete.defaults.controller = delete routes.delete.defaults.action = index routes.delete.id.reqs = "\d+"
here specify url match, in words starting colon :
variables. can see, can set requirements on variables regex-style. in example, id
1 or more digits, resulting in \d+
requirement on variable.
this route point url index
action of delete
controller , sets id
get-var. can alter .ini code suit specific needs.
the routes can added putting following code inside bootstrap:
$config = new zend_config_ini('/path/to/config.ini', 'production'); $router = new zend_controller_router_rewrite(); $router->addconfig($config, 'routes');
see docs more information: here general documentation , here .ini approach described.
Comments
Post a Comment