Hi Oleg,
As a solution (until perhaps mvlcek decides to add this feature), this may suffice (it is adapted from a similar question posed on StackOverflow). Define this function somewhere on your template:
Then to use it (e.g. in a component), fill in the appropriate parameters in the function to get your query and loop the results through a foreach (like below):
This will output your results in a random order on each page refresh.
Also mvlcek, can you please reupload your i18n_search_dummy.zip file? (Selfish of me perhaps, but I want to see if I can save some agony building a search function for MSGBoard by integrating i18n search in some way.)
As a solution (until perhaps mvlcek decides to add this feature), this may suffice (it is adapted from a similar question posed on StackOverflow). Define this function somewhere on your template:
Code:
<?php
function random_i18n_search_results($tags=null, $words=null, $first=0, $max=10, $order=null, $lang=null) {
$query = return_i18n_search_results($tags, $words, $first, $max, $order, $lang);
if (!is_array($query)) return $query; // failsafe to still return a value if $query isn't an array
$order = array_keys($query['results']); // gets keys of the query
shuffle($order); // reshuffles the array
$random = array(); // creates empty array to loop through
foreach ($order as $result) {
$random[] = $query['results'][$result]; // adds each result to the array
}
return $random; // returns results as an array with indices reordered
}
?>
Then to use it (e.g. in a component), fill in the appropriate parameters in the function to get your query and loop the results through a foreach (like below):
Code:
<?php
$results = random_i18n_search_results($tags='yourtags', $words='yourwords', $first=0, $max=10, $order='anyorder', $lang='anylang');
foreach ($results as $entry) {
// whatever you wish to output, e.g. "echo $entry->slug;" to get the slugs - you'll need to style these outputs to get exactly what you want
}
?>
This will output your results in a random order on each page refresh.
Also mvlcek, can you please reupload your i18n_search_dummy.zip file? (Selfish of me perhaps, but I want to see if I can save some agony building a search function for MSGBoard by integrating i18n search in some way.)