Multisearch Results Order

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 16, 2011   (RSS)

Re: [zip222] Multisearch Results Order

By Jason - June 16, 2011

Hi Zip,

Yes. What you can do is return up to 10 other fields by adding them to the table options arrays. For example, to return the updatedDate would be like this:

$searchTables['news'] = array(
'viewerUrl' => 'newsPage.php',
'titleField' => 'title',
'summaryField' => 'content',
'searchFields' => array('title'),
'field1' => 'updatedDate',

);


You would do this for each of your sections.

Next, put this function down at the bottom of your page:

<?php
function subval_sort($a,$subkey, $direction = "ASC") {
foreach($a as $k=>$v) {
$b[$k] = strtolower($v[$subkey]);
}
if ($direction == "DESC") {
arsort($b);
}
else {
asort($b);

}
foreach($b as $key=>$val) {
$c[] = $a[$key];
}
return $c;
}
?>


You can then sort your turned results by field1 like this:

$serachRows = subval_sort($searchRows,'field1','DESC');

You can replace DESC with ASC to switch from descending to ascending order.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Multisearch Results Order

By zip222 - June 16, 2011

Perfect. Thanks!

jason