Osclass Support Forums
Osclass theme support => Delta Osclass Theme => Topic started by: StefanGr 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.
• 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
<?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 )
-
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.
-
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....
-
@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 :)
-
@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....