Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get current page url and change action

I need to give current page url and change action url. After that I want echo that in view file. I want do these in view file, not controller!

Do you have any idea?

like image 767
afsane Avatar asked May 08 '11 10:05

afsane


2 Answers

You can get current page url as follows:

  $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

  // or using userAgent view helper:
  $uri = $this->userAgent()->getServerValue('request_uri');

The view helper $this->userAgent() returns an instance of Zend_Http_UserAgent that can provide you with many useful info.

If you want to get an action in your views you can get it as follows:

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

Not sure what you mean by 'changing an action'. You want to change it when you echo it, or you want to redirect user. Anyway, hope this will help.

like image 116
Marcin Avatar answered Oct 30 '22 00:10

Marcin


If your current scope is a controller action, you can do this:

$uri = $this->view->serverUrl() . $this->view->url();
like image 5
temuri Avatar answered Oct 30 '22 01:10

temuri