How can I add this into the pagination?
In the controller:
foreach ($posts as $findMatches) {
$q = $this->Post->find('first', array(
'conditions' => array('Post.id' => $findMatches),
'fields' => array(
'Post.id'),
'contain' => array(
'Language' => array('fields' => array('Language.id',
'Language.name')),
'Program' => array('fields' => array('Program.id' ,
'Program.name'))
)
));
$program_matches =
count(array_intersect($this->data['Program']['Program'], Set::extract($q,
'Program.{n}.id')));
$language_matches =
count(array_intersect($this->data['Language']['Language'], Set::extract($q,
'Language.{n}.id')));
$matches = $program_matches + $language_matches;
$searchCount = $searchProgramCount + $searchLanguageCount;
debug($percent = ceil(($matches/$searchCount)*100));
Basicaly a user does a search and I compare the search terms agints the
matches for each and get a % and I want the Posts to be ordered by matching
percentage from highest to lowest.
I tried 'order' => array( $percent => 'desc'), but I guess because percent
is something I made it will not find anythig to sort by.
How can I add $percent to $posts to then sort them?
Thanks,
Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---