开发者

cakephp: problem with PaginatorHelper and routing Plugins, cannot strip Plugin from url

开发者 https://www.devze.com 2023-01-11 14:32 出处:网络
I\'m using the Tags Plugin from cakedc.com, and I have a problem generating the proper paging links using the PaginatorHelper.

I'm using the Tags Plugin from cakedc.com, and I have a problem generating the proper paging links using the PaginatorHelper.

The desired result is to strip the plugin name from the generated hrefs, because the plugin will be added in routing. i.e. http://localhost/tags/photos/oregon/page:4/perpage:28

This is what I have:

app/config/routes.php (to map '/tags'=>'/tags/tags', i.e. to the Tags plugin)

Router::connect('/tags/:action/*', array('plugin'=>'tags', 'controller'=>'tags'));
// map /tags => /tags/tags

code in view file:

<?php 
   $this->Paginator->options['url']=array_merge(
              array('plugin'=>'tags'), 
              $this->Paginator->options['url'] 
   ); 
   echo $this->Paginator->numbers(array('separator'=>null, 'modulus'=>'20'));


// debug($this->Paginator->options[url] => Array
//        (
//            [controller] => tags
//            [action] => photos
//            [0] => oregon
//            [perpage] => 28
//            [page] => 4
//        )
// )

// sample href="开发者_StackOverflowhttp://localhost/tags/tags/photos/oregon/page:4/perpage:28"
//     note the '/tags/tags' i.e. /:plugin/:controller

?>

BU, I notice the following, if I set options['url'] as follows:

<?php 
   $this->Paginator->options['url']=array('plugin'=>'tags'); 
   echo $this->Paginator->numbers(array('separator'=>null, 'modulus'=>'20'));


// debug($this->Paginator->options[url] => Array
//    (
//        [plugin] => tags
//    )
// )
// sample href="http://localhost/tags/photos/page:4"

?>


This might help: http://bakery.cakephp.org/articles/view/secrets-of-admin-routing

But it looks like you are adding the PLUGIN array option to the URL. Why? If you are using routing, leave that off. When the link is clicked it will know how to handle it. In other words, don't enable routing AND use the plugin options on the URL at the same time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号