【问题标题】:CakePHP 2.2.4: Pagination LinksCakePHP 2.2.4:分页链接
【发布时间】:2012-11-26 18:39:59
【问题描述】:

我的网站有很多“页面”。页面针对不同的主题创建并由用户管理(例如,加勒比海盗页面或贾斯汀比伯页面)。该页面属于一个类别,例如电影或音乐。页面的默认 URL 是 http://www.example.com/category-directory/page-id。或者,如果版主想要建立自己的页面链接作为更简单的导航方式,他们可以通过为“Page.link”列赋予值来实现(例如:电影 Pirates 的 http://www.example.com/potc加勒比地区)。

我的路线都设置好了,这本身就需要一些时间。该路由检查“.com”之后的 URL 的第一个参数是否与任何页面的“链接”列匹配,如果匹配,则路由到该页面及其下的控制器/操作。如果没有,照常路线。

当用户查看http://www.example.com/potc/articles/99http://www.example.com/movies/106/articles/99 时(假设加勒比海盗 是id = 106 的页面),然后用户被定向到文章控制器,查看操作, id = 99. 106 作为 $page_id 传递给控制器​​的操作,并在 AppController 中设置。

我在控制器中提供的 URL 数组可以正常工作,例如,如果 id 不存在,我会重定向到 'controller' => 'articles', 'action' => 'index', 'page_id' = $page_id。我被重定向回http://www.example.com/potc/articles。我实际上不必定义控制器,因为默认情况下它使用当前控制器。

但是,我遇到了分页链接问题。例如,我在文章索引页面上,有 100 篇文章,但我只查看前 20 篇。我希望将 URL 输出为http://www.example.com/potc/articles/page:2

相反,如果我将 URL 数组设置为 'controller' => 'articles', 'action' => 'index', 'page_id' => $page_id,类似于我在控制器中所做的,我会得到链接 http://www.example.com/articles/page_id:106/page:2,我可以理解为什么这条路线不起作用,因为我可能必须传递值 Page。如果存在则链接,如果不传递 Category.directory 和 Page.id。我尝试使用 URL 数组 'controller' => 'articles', 'action' => 'index', 'category' => $page['Category']['directory'], 'page_id' => $page_id 执行后一个选项。我有一条与之匹配的路线,但分页链接仍然生成为http://www.example.com/articles/category:movies/page_id:106/page:2

这是我的 routes.php 中的一些 sn-ps:https://gist.github.com/9ba0a54a7f4d68803d14

我的问题是:“我可以使用准确的当前 URL 进行分页链接(减去对我所在的当前页面的引用)吗?”例如,如果我正在查看 http://www.example.com/dynamic-route/controller/id/page:2,则分页链接会自动转到http://www.example.com/dynamic-route/controller/id/page:3

我将所有分页代码放入一个元素中,并且我想将该元素包含在需要分页的视图文件中。

现在,如果我正在查看文章控制器、索引操作,分页链接的默认 URL 是 http://www.example.com/articles/page:2,但我需要它是 http://www.example.com/dynamic-route/articles/page:2

我尝试过使用

   $this->Paginator->options = array(
                    'url' => 'http://www.example.com/dynamic-route/articles'
   ); 

但链接的输出类似于http://www.example.com/articles/http://www.example.com/dynamic-route/articles/page:2

编辑: Jeztah,你提到放

'customlink' => '[a-z0-9]{1}([a-z0-9-]{2,}[a-z0-9]{1})?'

在我的路线上。好吧,我不能简单地这样做,因为路由会进行查询以检查 customlink 是否在数据库中,如果是则相应地路由。

我的路由器文件的一个例子是:

在获取 URL 的第一个参数 http://www.domain.com/CUSTOM-LINK 后,执行以下操作:

if($param1 != "users" && $param1){
    $pagelink = str_replace('-', ' ', $param1);

    $pagesModel = ClassRegistry::init('Page');
    $matchedpage = $pagesModel->find('first', array(
        'conditions' => array('Page.link LIKE' => "$pagelink"), 'recursive' => '-1'
    ));

    if($matchedpage['Page']['id']){
        Router::connect('/' . $param1 . '/:controller', array('action' => 'index', 'page_id' => $matchedpage['Page']['id']), array(
            'pass' => array('page_id'),
            'page_id' => '[0-9]+',
            'persist' => array('page_id'),
        ));

        Router::connect('/' . $param1 . '/:controller/:action/:id', array('page_id' => $matchedpage['Page']['id']), array(
            'pass' => array('page_id', 'id'),
            'page_id' => '[0-9]+',
            'persist' => array('page_id'),
        ));


        Router::connect('/' . $param1 . '/:controller/:id', array('action' => 'view', 'page_id' => $matchedpage['Page']['id']), array(
            'pass' => array('page_id', 'id'),
            'page_id' => '[0-9]+',
            'id' => '[0-9]+',
            'persist' => array('page_id'),
        ));


        Router::connect('/' . $param1 . '/:controller/:action', array('page_id' => $matchedpage['Page']['id']), array(
            'pass' => array('page_id'),
            'page_id' => '[0-9]+',
            'persist' => array('page_id'),
        ));

    } // end if page matches
} // end if param1 is not users

如果我转到http://www.domain.com/custom-link/articleshttp://www.domain.com/custom-link/articles/1http://www.domain.com/custom-link/articles/edit/1 等,则会显示正确的页面。如果我尝试导航到自定义链接不存在的页面,请继续查看我的路由器文件,如果没有其他路由匹配,则抛出错误消息。一切都很好。

在我的 ArticlesController.php 中,重定向方法按预期工作。例如,我尝试转到http://www.domain.com/custom-link/articles/99,但 id 99 不存在,我使用

正确重定向回http://www.domain.com/custom-link/articles

$this->redirect(array('action' => 'index', 'page_id' => $page_id), 空,真);

但是,在分页上,我将 url 选项设置为

array('controller' => 'articles', 'action' => 'index', 'page_id' => $page_id);

其中 $page_id 在 AppController 中设置为由路由器传递。虽然我不需要设置控制器和动作,因为将使用电流。同样,我的分页链接显示为 http://www.domain.com/articles/page_id:3/page:2 而不是我想要的 http://www.domain.com/custom-link/articles/page:2

编辑:杰兹塔

我刚刚将整个路由文件更改为具有自定义链接参数的文件(我重命名为“链接”),然后创建了一个组件以在应用程序控制器中使用以从链接中获取页面 ID。

示例路线

Router::connect('/:link/:controller/:action/:id', array(), array(
    'pass' => array('link', 'id'),
    'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
    'persist' => array('link'),
));


Router::connect('/:link/:controller/:id', array('action' => 'view'), array(
    'pass' => array('link', 'id'),
    'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
    'id' => '[0-9]+',
    'persist' => array('link'),
));

但是,如果将 url 数组分页为 array('link' => 'test-example'),则 url 会输出为 http://www.domain.com/articles/link:test-example/page:2。我的代码与您的代码完全相同,减去将“自定义链接”重命名为“链接”。此外,现在我的路线无法区分我是否尝试访问http://www.domain.com/custom-link,这将是 'controller' => 'pages'、'action' => 'view' (他的页面基本上会使用 News 模型和显示该页面的最新消息),如果我尝试访问http://www.domain.com/articles,这将是“控制器”=>“文章”,“操作”=>“索引”,它将显示所有页面的最新文章。请注意,文章和新闻是不同的模型。

Router::connect('/:link', array('controller' => 'pages', 'action' => 'view'), array(
    'pass' => array('link'),
    'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
    'persist' => array('link'),
));

一样
Router::connect('/:controller', array('action' => 'index'));

因为在路由中不再检查“链接”是否属于特定页面。

编辑:好的,我正在取得进展。我发现下一个和上一个分页链接不太适合 paginator->options。我删除了 paginator->options 并将下一个按钮的 url 数组留空。链接输出为http://www.domain.com/articles/custom-link/articles/page:2。进步!但是有什么办法可以赶上第一个“文章/”吗?

我的路线是

Router::connect('/:link/:controller/*', array(), array(
    'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
));

【问题讨论】:

  • 您应该动态创建路由,而是将“自定义链接”作为参数传递给控制器​​。这样,控制器将检查是否可以找到自定义链接,否则将显示常规 404(如果找不到页面,则应该如此)。您可能会考虑将自定义网址设为 必需,如果用户没有提供,请生成一个,但它应该是唯一的。如果为每个请求动态生成路由,CakePHP 将不得不为每个请求重新构建路由,这对性能不利

标签: php cakephp pagination routes paginator


【解决方案1】:

最好使用相对路径:

   $this->Paginator->options = array(
                    'url' => '/dynamic-route'
   );
Or:
   $this->Paginator->options = array(
                    'url' => '/dynamic-route/articles'
   ); 
Or:
   $this->Paginator->options = array(
                    'url' => array('controller'=>'dynamic-route')
   );

或者 开始在您的路由器文件中构建自定义路由 http://api.cakephp.org/class/router#method-Routerurl

【讨论】:

【解决方案2】:

如果你正确地构建你的路线,这应该会自动运行:

在你的 routes.php 中

/**
 * Movies view/details page
 */
Router::connect(
    '/:link',
    array(
         'controller'  => 'movies',
         'action'      => 'view',
    ),
    array(
         /**
          * Custom Link:
          * lowercase alphanumeric and dashes, but NO leading/trailing dash
          * should be at least 4 characters long
          *
          * IMPORTANT:
          * custom links should *NOT* overlap with actual controller
          * names, like 'movies, articles' etc!
          */
         'link'   => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',

         // Define what should be passed to the 'view' action as arguments
         'pass'         => array('link'),

         /**
          * Define what parameters should be automatically preserved
          * when creating URLs/links
          */
         'persist' => array('link'),
    )
);

/**
 * Article view/details page
 */
Router::connect(
    '/:link/:controller/:page_id',
    array(
         'controller'  => 'articles',
         'action'      => 'view',
    ),
    array(
         /**
          * Specify the 'controllers' that are allowed to be put
          * after link. You can add more, for example
          * 'reviews' to show reviews for a movie. this
          * will result in Reviews::view([page_id]) to be shown
          */
         'controller' => 'articles',
         'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
         'page_id'  => '[1-9]{1}[0-9]{0,}',

         // Define what should be passed to the 'view' action as arguments
         'pass'       => array('page_id', 'link'),

         /**
          * Define what parameters should be automatically preserved
          * when creating URLs/links
          */
         'persist' => array('page_id', 'link'),
    )
);

/**
 * Article overview/index page
 */
Router::connect(
    '/:link/:controller/*',
    array(
         'controller'  => 'articles',
         'action'      => 'index',
    ),
    array(
         'controller' => 'articles',
         'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',

         // Define what should be passed to the 'index' action as arguments
         'pass'       => array('link'),

         /**
          * Define what parameters should be automatically maintained
          * when creating URLs/links
          */
         'persist' => array('page_id', 'link'),
    )
);

打开 http://example.com/potc 时,您将被带到 Movies::view('potc')

打开 http://example.com/potc/articles 时,您将被带到 Articles::index('potc')

打开http://example.com/potc/articles/page:2 时,您还将被带到Articles::index('potc')。 “页面”将作为命名参数传递

打开 http://example.com/potc/articles/99 时,您将被带到 Articles::view(99, 'potc')

在您的文章/index.ctp 视图中:

debug($this->Html->link('current page', array()));
// outputs:
// <a href="/potc/articles/">current page</a>

debug($this->Html->link('next page', array('page' => 2)));
// outputs:
// <a href="/potc/articles/page:2">next page</a>

debug($this->Html->link('view article', array('action' => 'view', 'page_id' => 99)));
// outputs:
// <a href="/potc/articles/99">view article</a>

访问分页链接 (http://example.com/potc/articles/page:2/sort:title/dir:desc)

debug($this->request);

输出:

object(CakeRequest) {
    params => array(
        'plugin' => null,
        'controller' => 'articles',
        'action' => 'index',
        'named' => array(
            'page' => '2',
            'sort' => 'title',
            'dir' => 'desc'
        ),
        'pass' => array(
            (int) 0 => 'potc'
        ),
        'link' => 'potc',
        (int) 0 => 'page:2/sort:title/dir:desc',
        'paging' => array(
            'Article' => array(
                'page' => (int) 1,
                'current' => (int) 0,
                'count' => (int) 3,
                'prevPage' => false,
                'nextPage' => false,
                'pageCount' => (int) 1,
                'order' => array(),
                'limit' => (int) 10,
                'options' => array(
                    'page' => (int) 2,
                    'sort' => 'title',
                    'order' => array(),
                    'conditions' => array()
                ),
                'paramType' => 'named'
            )
        ),
        'models' => array(
            'Article' => array(
                'plugin' => null,
                'className' => 'Article'
            )
        )
    )
    data => array()
    query => array()
    url => 'potc/articles/page:2/sort:title/dir:desc'
    base => ''
    webroot => '/'
    here => '/potc/articles/page:2/sort:title/dir:desc'
}

如您所见,您需要的所有信息都在请求对象中

[OP 修改后更新]

我看到您在这条路线中使用了 ':id':

/:link/:controller/:action/:id

但是您没有为此添加正则表达式。 另外,我认为您不想使用这条路线,因为要匹配这条路线, 您必须在您的 URL 中包含该操作。例如:

/test-example/articles/view/1

这条路线的更好选择是我原来的例子中的这条路线:

/:link/:controller/:page_id

这将路由到:

Controller::view('page_id', 'link')

正如我之前提到的,添加路由的“顺序”决定了首先匹配的内容, 因此,如果您在包含 CakePHP 默认路由之前添加了路由,那么您的路由将是首选。

在这种情况下; /测试示例/ /页/

将始终与 '/:link' 匹配,因此 /pages/view/test-example,如果您传递了有效的控制器名称(!) 为了防止这种情况发生,您应该在包含 CakePHP 默认路由之后添加您的路由。

如果您添加路线 /:链接/:控制器/

然后这个网址: /test-example/某事

在“某物”是已知控制器时才匹配

/:link/:controller/:action/:id

如果 'controller' 是已知的控制器,将匹配,任何操作都将被 'accepted',但是 如果您尝试访问它,将导致“未找到异常”。也(如上所述) 你应该为'id'添加一个正则表达式

您添加的最后一条路线:

Router::connect('/:link/:controller/*', array(), array(
    'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
));

缺少默认的 'action' 参数,因此 CakePHP 可能无法匹配, 这应该是:

Router::connect('/:link/:controller/*', 
    array(
        'action' => 'index',
    ), array(
    'link' => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
));

这样,它会匹配:

/any-link/controllername/pass1
/any-link/controllername/pass1/pass2
etc.

分别是'pass1, pass2' 将作为参数发送到控制器的动作, 例如:

/test-example/articles/some/thing/else

将被路由到:

ArticlesController::index('some', 'thing', 'else');

我认为你的路线的最佳顺序是:

  1. Cake 默认路由
  2. /:link (-> pages::view('link'))
  3. /:link/:controller/:id (-> controller::view('id', 'link))
  4. /:link/:controller/* (-> controller::index('link'))

注意最后两条路线的顺序; Route 3 仅在 'id' 为数值时才会匹配,从而导致 'view' 动作被路由 Route 4 将匹配控制器之后的“任何东西”,并显示控制器的“索引”操作

【讨论】:

  • 感谢您的回复,但我仍然没有得到“下一页”的预期结果。当我想获取时,我得到的网址是domain.com/articles/page_id:3/page:2:http:www.domain.com/custom-link/articles/page:2。请查看我的最新编辑
  • 我看到,在我的示例中,我使用的是 'articleId' 而不是 'page_id',要我更改它吗?
  • 我编辑了我的示例,但是,您可能需要阅读我的代码中的 cmets 并尝试“了解”各种设置的含义。我无权访问您的所有代码,因此我不得不假设您正在使用的一些控制器/操作/参数的名称(例如,我将 'customlink' 用于 'dynamic-url' 部分
【解决方案3】:

编辑:在我意识到我的上一个答案在涉及 ArticlesConntroller::redirect 时存在缺陷后,这是一个编辑过的答案

对于已成功阅读整个问题/cmets 并希望知道答案的任何人。感谢 Jeztah 的帮助,我想出了一个解决方案,我将把这笔赏金授予他。让我很难过的一个问题是一个页面可能有 2 个 URL。例如:http://www.domain.com/potchttp://www.domain.com/movies/106。 基本上我结合了我和 Jeztah 的想法。

首先,我必须检查 routes.php 以查看 .com 之后的第一个参数是否与页面的快捷方式“链接”匹配(例如:http://www.domain.com/potc = potc)。

// get params of URL
$requestURI = explode('/', $_SERVER['REQUEST_URI']);
$scriptName = explode('/',$_SERVER['SCRIPT_NAME']);

for($i= 0;$i < sizeof($scriptName);$i++) {
      if ($requestURI[$i]     == $scriptName[$i]) {
                unset($requestURI[$i]);
        }
      }
 $param = array_values($requestURI);

// only concerned about first param
$param1 = $param[0];

// do the following routes if url != http://www.domain.com/users/* or http://www.domain.com
if($param1 != "users" && $param1){

    // convert http://www.domain.com/assassins-creed to "assassins creed"
    $pagelink = str_replace('-', ' ', $param1);
    $pagesModel = ClassRegistry::init('Page');
    // check if there is a page whose "link" matches converted link, if so, get the field "id"
    $matched_page_id = $pagesModel->field('id', array('Page.link LIKE' => "$pagelink"));
    // if there is a match, route as follows
    if($matched_page_id){

         // Jeztah's way with some modifications

        // domain.com/potc/articles/edit/1
        Router::connect(
            '/:link/:controller/:action/:id',
            array('page_id' => $matched_page_id, 'category' => 0),
            array(
                'pass' => array('id', 'link', 'category', 'page_id'),
                'link'   => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
                'persist' => array('link'),
                'id' => '[0-9]+'
            )
        );

        // domain.com/potc/articles/1
        Router::connect(
            '/:link/:controller/:id',
            array('action' => 'view', 'page_id' => $matched_page_id, 'category' => 0),
            array(
                'pass' => array('id', 'link', 'category', 'page_id'),
                'link'   => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
                'persist' => array('link'),
                'id' => '[0-9]+'
            )
        );

        // domain.com/potc/articles/add
        Router::connect(
            '/:link/:controller/:action',
            array('page_id' => $matched_page_id, 'category' => 0),
            array(
                'pass' => array('link', 'category', 'page_id'),
                'link'   => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
                'persist' => array('link'),
                'action' => 'add|uncategorized',
            )
        );

        // domain.com/potc/articles OR domain.com/articles/page:2
        Router::connect(
            '/:link/:controller/*',
            array('action' => 'index', 'page_id' => $matched_page_id, 'category' => 0),
            array(
                'pass' => array('link', 'category', 'page_id'),
                'link'   => '[a-z0-9]{1}([a-z0-9\-]{2,}[a-z0-9]{1})?',
                'persist' => array('link'),
            )
        );
    }  // end if first param matches a page's "link" shortcut
}  // end if first param is not users and is not empty

// do some general site routing
// do some general site routing

// now route for page's that do not have a link shortcut (example: http://www.domain.com/movies/106)

// domain.com/movies/106/articles/edit/1
Router::connect(
    '/:category/:page_id/:controller/:action/:id',
    array('link' => '0'),
    array(
        'pass' => array('id', 'link', 'category', 'page_id'),
        'page_id' => '[0-9]+',
        'id' => '[0-9]+'
    )
);

// domain.com/movies/106/articles/1
Router::connect(
    '/:category/:page_id/:controller/:id',
    array('action' => 'view', 'link' => '0'),
    array(
        'pass' => array('id', 'link', 'category', 'page_id'),
        'page_id' => '[0-9]+',
        'id' => '[0-9]+'
    )
);

// domain.com/movies/106/articles/add
Router::connect(
    '/:category/:page_id/:controller/:action',
    array('link' => '0'),
    array(
        'pass' => array('link', 'category', 'page_id'),
        'page_id' => '[0-9]+',
        'action' => 'add|uncategorized'
    )
);

// domain.com/movies/106/articles OR domain.com/movies/106/articles/page:2
Router::connect(
    '/:category/:page_id/:controller/*',
    array('action' => 'index', 'link' => '0'),
    array(
        'pass' => array('link', 'category', 'page_id', 'controller'),
        'page_id' => '[0-9]+'
    )
);

因为 page_id 在 :link 路由和 :category 路由中都被传递,所以我不必按照建议使用获取页面 id 的组件。

现在在我的 ArticlesController

public function index($link = null, $category = null, $page_id = null, $controller = null) {
    if($page_id){

         // display all articles for a particular page if on
         // http://www.domain.com/potc/articles or http://www.domain.com/movies/106/articles
        $this->set('articles', $this->paginate('Article', array('Article.page_id' => $page_id, 'Article.status <= 5'))); 
    }
    else{

        // display all articles if on http://www.domain.com/articles
        $this->set('articles', $this->paginate('Article', array('Article.status <= 5')));
    }    
} // end index function

public function view($id = null, $link = null, $category = null, $page_id = null) {
    $this->Article->id = $id;
    $article_page = $this->Article->field('page_id', array('id =' => $id));

    if (!$this->Article->exists()) {
        $this->Session->setFlash('This article does not exist');

        // using PageLinkRedirect function of my custom component,
        // determine where to redirect. Either to "potc/articles" or
        // "movies/106/articles";
        $this->redirect('../'.$this->CustomPage->PageLinkRedirect($link, $category, $page_id).'/articles', null, true);
    }
    elseif($article_page != $page_id) {
        $this->Session->setFlash('Invalid article for this page');

        // using PageLinkRedirect function of my custom component,
        // determine where to redirect. Either to "potc/articles" or
        // "movies/106/articles";
        $this->redirect('../'.$this->CustomPage->PageLinkRedirect($link, $category, $page_id).'/articles', null, true);
    }
    else{
        $this->set('title_for_layout', $this->Article->field('title', array('id =' => $id)));
        $this->set('article',  $this->Article->read(null, $id));
        $this->set('comments', $this->paginate($this->Article->Comment, array('Comment.module_id' => $this->viewVars['module_id'], 'Comment.post_id' => $id)));
    } // end else
} // end view function

我的分页存储在一个元素中,但我在 Articles index.ctp 视图的底部加载了该元素

<?php echo $this->element('all/pagination', array('pagination_url' => 'articles')); ?>

我会为每个不同的控制器放置相同的代码,但更改“文章”一词(例如:“评论”、“新闻/主题”等)

我的 pagination.ctp 元素看起来像这样

<?php
if($this->params['paging'][key($this->params['paging'])]['pageCount'] > 1){
    $pagination_class = "pagination_enabled";
}
else{
    $pagination_class = "pagination_disabled";
}
 ?>
<div class="<?php echo $pagination_class; ?>">
<?php echo $this->Paginator->counter(array(
    'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
)); 
?>
<ul>
<?php

// $link is set in AppController from the link param, same with category and page_id
if($link){
    $this->Paginator->options = array('url' => array('controller' => null, $link, $pagination_url));

    // This outputs http://www.domain.com/potc/articles where articles
    // is from the passed $pagination_url when I loaded the element
    // in my Articles index.ctp view. I have to set controller = null
    // or else the link will output as http://www.domain.com/articles/potc/articles
}
else{
    $this->Paginator->options = array('url' => array('controller' => null, 'link' => null, $category, $page_id, $pagination_url));

    // This outputs http://www.domain.com/movies/106/articles where articles
    // is from the passed $pagination_url when I loaded the element
    // in my Articles index.ctp view. I have to set controller = null AND
    // link = null or else the link will output as
    // http://www.domain.com/articles/0/movies/9/articles
} 
echo $this->Paginator->prev('< ' . __('previous'), array('tag' => 'li'), null, array('class' => 'prev disabled'));
if($this->Paginator->numbers){echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => ''));}
echo $this->Paginator->next(__('next') . ' >', array('tag' => 'li'), null, array('class' => 'next disabled'));
?>
</ul></div>

【讨论】:

  • 我根据您添加的路线添加了一些附加信息,问题是,我在这里一切正常,但我怀疑您的某些路线顺序错误,导致它们匹配到错误的路线
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-06
  • 1970-01-01
  • 2012-11-24
  • 2015-02-13
  • 2014-06-05
相关资源
最近更新 更多