0

How to get parameters from below url

domain.com/admin/edit/12

I want to access this value (12) in edit function.

I searched around but didn't found any inbuilt solution in zend framework. Even in other framework it works easily. Like in codeIgnitor it works as segment and function parameter.

2
  • you want answer for codeigniter or zend-framework Commented Jan 14, 2014 at 6:55
  • @saurabh2836 can you read properly, I am looking solution like CI. Commented Jan 14, 2014 at 10:06

1 Answer 1

1

How I can see from code , you have Admin_Controller & some action edit ( by default routing) . For getting edit value , U need generate urls like domain.com/admin/edit/id/12/ (for example) . And than in action edit use next:

$id = $this->_request->getParam('id',0);
if ($id){
   //get info for edit by ID 
}

EDIT

IF you still want urls like domain.com/admin/edit/12, do next:

$uri = $this->_request->getRequestUri(); // or $this->getRequest()->getRequestUri() 
$id = intval(end(explode('/',$uri)));
if($id){
  // do something 
}
Sign up to request clarification or add additional context in comments.

5 Comments

This way all works fine but requirement is to show url as domain.com/admin/edit/12. Is this framework does not provide such feature. In CI it works by default.
Its looks near by the solution. Is zend framework does not have inbuilt or using route.
@PraveenD ZF has it all
which first option? and how it ti right? I am expecting as in CI
@PraveenD "first option" - where id exists in url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.