Hi Guys,

I had the same problem couple weeks ago. The paginationCount function
doesn't work well with i18n tabel. It gets confused on table name.
Luckily we can overwrite this function to return us a proper number of
records. It's a bit tricky I think but it works well for me.


1. Put these sample functions in your model or app_model

        function setPaginate($method=''){
                if (empty($method)){
                        $this->usePaginateMethod = 'standard';
                }else{
                        $this->usePaginateMethod = $method;
                }
        }


        function paginateCount($conditions, $recursive, $extra){

                switch ($this->usePaginateMethod) {
                        case 'standard':
                                return 
$this->standardPaginateCount($conditions, $recursive,
$extra);
                                break;

                        case 'customized':
                                //using same standard for now
                                return 
$this->customizedPaginateCount($conditions, $recursive,
$extra);
                                break;
                }

        }

        function standardPaginateCount($conditions, $recursive, $extra){
                        $results = $this->find('count', compact('conditions', 
'recursive',
'extra'));
                        return $results;
        }
        function customizedPaginateCount($conditions, $recursive, $extra){
                        $results = $this->find('all', compact('conditions', 
'recursive',
'extra'));
                        $count = count($results);
                        return $count;
        }



2.  Apply two extra lines in controller before calling a paginate
function.

                $this->Course->setPaginate('customized');               
//specify to use
customizedPaginateCountfunction
                $courses = $this->paginate('Course',$options['conditions']);
                $this->Course->setPaginate('standard');                        
//set back to
standard one, just in case we use normal paginate



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to