Yii2 LinkPager CAP



  • How do you build a LinkPager? The rule.

    [
        'pattern' => 'news/<page:\d+>',
        'route' => '/news/index'
    ], 
    

    In action:

    $pages = new Pagination([
        'route' => 'news/',
        'totalCount' => $countQuery->count(),
        'pageSize' => self::PAGE_SIZE,
        'forcePageParam' => false,
        'pageSizeParam' => false,
    ]);
    

    Still, LinkPager Generates the reference to the species

    /news?page=2

    Reference to type

    /news/2

    It works.

    What am I doing?



  • Route means "controller/action," not url. It's by the matching name of the controller and the Yii2 eqshen changes the reference. Try to get the slash out of the Route.

    'route' => 'news/index'

    or do so

    [
        'news/index' => 'news/<page:\d+>',
    ], 
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2