*

StefanGr

  • ***
  • 51 posts
Random Premium Ads
« on: July 22, 2022, 08:59:00 PM »
Hello,
I would love a little help.

Iv managed to make my premium ads show randomly, by modifying some core files of osclass Search , and changing the search, and using this steps.

Code: [Select]

• Find "getPremiums($max = 2)" and replace it with "getPremiums($max = 2, $random = false)".

• Find "$this->_makeSQLPremium($max)" and replace it with "$this->_makeSQLPremium($max, $random)".

• Find "_makeSQLPremium($num = 2)" and replace it with "_makeSQLPremium($num = 2, $random)".

• Find "$this->dao->orderBy(sprintf('SUM(%st_item_stats.i_num_premium_views)', DB_TABLE_PREFIX), 'ASC');" and replace it with

if(!$random) {
    $this->dao->orderBy(sprintf('SUM(%st_item_stats.i_num_premium_views)', DB_TABLE_PREFIX), 'ASC');
}


And on search.gallery
<?php  osc_get_premiums(del_param('premium_home_count'), true); ?>





However, i'm using another mods, to only show specific ads from specific categories, by using this

Code: [Select]
<?php 

        $search_cat_id 
osc_search_category_id();

        
$search_cat_id = isset($search_cat_id[0]) ? $search_cat_id[0] : '';



        
View::newInstance()->_exportVariableToView('premiums'del_premium_items(del_param('premium_home_count' ),  $search_cat_id)); 

      
?>



Now.. if i comment the "custom" display , my random will work, but showing ads that are not suposed to be shown.
Here i'm lost....  can i have a bit of help, to randomly display them, without the ads i don't want ? ( based on the new View instance )



;) nothing here, move on.

*

MB Themes

Re: Random Premium Ads
« Reply #1 on: July 23, 2022, 08:08:05 AM »
You probably have problem in del_premium_items.
Anyway by removing "order by" from query, it should not mean it will result data in random order.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: Random Premium Ads
« Reply #2 on: July 23, 2022, 11:04:59 AM »
The solution given is no solution.... In 2016 teseo posted this on forum osclass and it worked on bender for some they said.  It is not that simple otherwise everyone has it. Everyone wants the premiums in random order....

*

MB Themes

Re: Random Premium Ads
« Reply #3 on: August 01, 2022, 12:00:38 PM »
@mwindey
Problem with "random" is that first you need to get somehow list of IDs those are in random order and then use these ids to retrieve items from database.
Cache, memcache and other similar techniques will be "against" random pick :)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: Random Premium Ads
« Reply #4 on: August 02, 2022, 01:30:48 PM »
@MB Themes,
Correct!
One other thing:
At the moment the premiums are displayed in order so the last added premium is at the end.
It could help if they where in reversed order and latest added premium comes first....