获取当前页面的URL并更改操作 [英] get current page url and change action

查看:158
本文介绍了获取当前页面的URL并更改操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要提供当前页面的网址并更改操作网址。之后,我想在视图文件中回显该信息。
我想在视图文件中执行这些操作,而不是在控制器中执行!

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!

您有任何想法吗?

推荐答案

您可以按如下方式获取当前页面的网址:

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');

视图助手 $ this-> userAgent()返回 Zend_Http_UserAgent 的实例,该实例可以为您提供许多有用的信息。

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.

这篇关于获取当前页面的URL并更改操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆