0

I am trying this code:

Zend_Controller_Front::getInstance()->getRequest()->getControllerName()
Zend_Controller_Front::getInstance()->getRequest()->getActionName()

I get this error:

Zend_Controller_Front Class Not Found

5
  • 1
    Are you in a namespace in your view? If so, try \Zend_Controller_Front. That said, your view probably isn't the best place for this - I would do it in your controller and pass any results to your view as necessary. Commented Feb 3, 2015 at 15:49
  • 2
    (We appreciate the use of formatting tools here, by the way - code formatting for code, quote formatting for errors, adding descriptive text - makes everything a bit more readable). Commented Feb 3, 2015 at 15:50
  • Thanks halfer sir! I want put check on the controller and action basis this is my requirement. i understand you completely but the issue is \Zend_Controller_Front not found error comes. Sir can you send me some example...Please. Commented Feb 4, 2015 at 11:07
  • There's not enough information here to be able to assist. Have you loaded Zend manually? If so, how? Or do you use an autoloader? Can we see the view and controller files edited into your question? Commented Feb 4, 2015 at 11:10
  • Sorry that this is not an direct answer to your question, but what I think that getting controller or action name in the view seems to be bad architecture. Not sure why do you need it, but concider one more time your task from the higher point of view. Commented Feb 4, 2015 at 21:30

1 Answer 1

1

I am giving answer on the basis of what i have get from your question it might be wrong but from my point of view I am giving this answer.

$action= $this->getEvent()->getRouteMatch()->getParam('action');

$controller= $this->getEvent()->getRouteMatch()->getParam('controller');

you can write this in controller and pass this variables in view model.

$view = new ViewModel(array('action' =>$action,'controller' =>$controller));
$view->setTemplate("tournamentview/index/getTeam.phtml");
return $view;

and you can access action and controller variable in view i.e. getTeam.phtml file.$action will give you the action Name and the $ controller will give you the alias of controller like 'TournamentView\Controller\Index' hope it will work

Sign up to request clarification or add additional context in comments.

Comments

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.