Help to stop randomizing search results across mulitple pages

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 15, 2010   (RSS)

Hey guys,

We have our results viewers setup to show all of our listings randomly. We have it setup this way in order to allow our customers to have an "equal" chance at getting there listings seen. The problem we run into is that once a user goes to a second page in the results and clicks the previous button or clicks the back button in their browser the Random function "re-randomizes" the results making the search not very usable. We want to do something that only randomizes the listings once for a particular user. Or maybe remembers where the listings were as the user clicks through the multiple pages of results.

We do not require potential renters to setup an account so they are not logged into our system in any way. I think this could be setup using cookies or better yet sessions?

thanks!
Lauren
Jason Glass

Re: [rentittoday] Help to stop randomizing search results across mulitple pages

By Chris - September 13, 2010 - edited: September 15, 2010

Hi Lauren,

Here's a sneaky solution for you.

// if the visitor doesn't have a random_string, assign them a new one
if (!@$_SESSION['random_string']) { $_SESSION['random_string'] = uniqid(''); }

// load records
list($exampleRecords, $exampleMetaData) = getRecords(array(
'tableName' => 'example',
'perPage' => '5',
'orderBy' => mysql_escapef('MD5(CONCAT(?, num))', $_SESSION['random_string']),
));


Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [rentittoday] Help to stop randomizing search results across mulitple pages

By Chris - September 15, 2010 - edited: September 15, 2010

Hi Lauren,

The first line there is meant to define the 'random_string' element if it's not already defined:

if (!@$_SESSION['random_string']) { $_SESSION['random_string'] = uniqid(''); }

Could you email me your FTP information and I'll see if I can get this figured out for you? chris@interactivetools.com
All the best,
Chris