【问题标题】:Cakephp routes and displaying data by idCakephp 路由并按 id 显示数据
【发布时间】:2012-08-13 17:44:11
【问题描述】:

我正在考虑 cake 的路由,但是在显示 diff 中的一个表中的数据时遇到了问题。意见。

我有一个带有 news_type_id 标记的文章的新闻表。 我将每个路由设置为显示调用 requestAction 的视图并按特定 news_type id 列出新闻文章。

//--index of news articles with news_type_id = 1
/section1/

//--index of news articles with news_type_id = 2 etc
/section2/

我的路线设置如下:

Router::connect('/section1', array('controller' => 'pages', 'action' => 'display', 'section1'));

但问题是我一尝试:

Router::connect('/section1', array('controller' => 'pages', 'action' => 'display', 'section1'));
Router::connect('/section2', array('controller' => 'pages', 'action' => 'display', 'section2'));

...当然,actions 会返回到顶部路由(section1)。

有人可以指出对我来说显而易见的事情吗?

【问题讨论】:

    标签: url cakephp routing routes


    【解决方案1】:

    我会尝试:

    Router::connect('/section1', array('controller' => 'pages', 'action' => 'display', array('mysection'=>'section1')));
    Router::connect('/section2', array('controller' => 'pages', 'action' => 'display', array('mysection'=>'section2')));
    

    在操作中我会得到 mysection 作为参数

    希望对你有帮助

    问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-22
      • 1970-01-01
      • 2021-10-10
      • 2014-03-16
      相关资源
      最近更新 更多