【问题标题】:Zend_Framework how to get the two URL ParametersZend_Framework 如何获取两个 URL 参数
【发布时间】:2016-09-26 15:47:12
【问题描述】:

我有一个构建服务器 (http://url.server.zip/release),其中包含带有一些数字的 zip 文件列表。例如。 http://url.server.zip/release/first_release_1,http://url.server.zip/release/first_release_2等等……

查看:在我的查看页面中,我从搜索框中开发了一个搜索框,我需要从该服务器(http://url.server.zip/release)中搜索字符串,然后我必须在前视图页面中显示发布 zip 文件。

public  function viewPostAction() {
  $this->params()->fromRoute('page', 1);
  return new ViewModel();
}   

【问题讨论】:

    标签: zend-framework


    【解决方案1】:

    我不确定我是否真的理解你的问题,但我会试一试。

    无论您的情况如何,一般来说,您都必须在路由中设置两个参数的名称(module.config.php)。例如,我想在 url 中获取主题的 id 和名称:

    'theme' => array(
                    'type' => 'Zend\Mvc\Router\Http\Segment',
                    'options' => array(
                        'route'    => '/theme/[:themeId]/[:themeName]', 
                         ...
    

    [] 表示在链接中使用参数不是强制性的。由您决定是否要强制执行。

    URL 类似于“http://test.com/12/testing”。然后,您将能够通过这种方式获取这两个参数:

    $themeId = $this->params()->fromRoute('themeId');
    $themeName = $this->params()->fromRoute('themeName');
    

    $themeId = 12 和 $themeName = 测试,如果我们按照示例进行。

    希望它是您想要的。如果没有,您能否给我们更多信息?比如你的路由文件等等。

    【讨论】:

      猜你喜欢
      • 2020-06-29
      • 2019-02-11
      • 2017-12-18
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      相关资源
      最近更新 更多