Advertisement:

Author Topic: Most Viewed Ads  (Read 56624 times)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Most Viewed Ads
« Reply #150 on: December 01, 2015, 01:36:20 am »
Yes, that's my own modification... :D

Try changing this line:

Code: [Select]
    $item_array=$conn->osc_dbFetchResults("SELECT i.*, l.*, d.*, SUM(s.i_num_views) AS total_views FROM %st_item_stats s
JOIN %st_item i ON s.fk_i_item_id = i.pk_i_id
JOIN %st_item_location l ON s.fk_i_item_id = l.fk_i_item_id
JOIN %st_item_description d ON s.fk_i_item_id = d.fk_i_item_id
WHERE i.fk_i_category_id IN(%s)
AND i.b_enabled = 1 AND i.b_active = 1 AND i.b_spam = 0 AND (i.b_premium = 1 || i.dt_expiration >= CURDATE())
GROUP BY s.fk_i_item_id
ORDER BY total_views DESC
LIMIT 0, %d", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, $catsToInclude, $num_ads);

to

Code: [Select]
    $item_array=$conn->osc_dbFetchResults("SELECT i.*, l.*, d.*, SUM(s.i_num_views) AS total_views FROM %st_item_stats s
JOIN %st_item i ON s.fk_i_item_id = i.pk_i_id
JOIN %st_item_location l ON s.fk_i_item_id = l.fk_i_item_id
JOIN %st_item_description d ON s.fk_i_item_id = d.fk_i_item_id AND d.fk_c_locale_code = '%s'
WHERE i.fk_i_category_id IN(%s)
AND i.b_enabled = 1 AND i.b_active = 1 AND i.b_spam = 0 AND (i.b_premium = 1 || i.dt_expiration >= CURDATE())
GROUP BY s.fk_i_item_id
ORDER BY total_views DESC
LIMIT 0, %d", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX, osc_current_user_locale(), $catsToInclude, $num_ads);

Regards

fog

  • Hero Member
  • *****
  • Posts: 1062
Re: Most Viewed Ads
« Reply #151 on: December 01, 2015, 01:57:01 am »
Ah... now works!

But with <?php echo osc_item_field('s_title') ; ?>

I tried before with <?php echo osc_item_title() ?> but, nothing appeared.

Thank you so much teseo! God bless you  :D

Yes is your own modification  :D and works very well  8)
Have a good week!
Regards

fog

  • Hero Member
  • *****
  • Posts: 1062
Re: Most Viewed Ads
« Reply #152 on: December 02, 2015, 11:39:59 pm »
Dude, I guess you posting on wrong thread.
Regards

Shafi

  • Newbie
  • *
  • Posts: 38
  • shoot only if you can kill.
Re: Most Viewed Ads
« Reply #153 on: April 05, 2016, 02:12:55 pm »
I think this plugin is not working with the OS class version 3.6.1

fosg2000

  • Jr. Member
  • **
  • Posts: 82
Re: Most Viewed Ads
« Reply #154 on: June 07, 2016, 08:59:19 pm »
hi, can anyone updated this plugin to the last version ?


thanks

arsko

  • Newbie
  • *
  • Posts: 2
  • Разработка сайтов
Re: Most Viewed Ads
« Reply #155 on: February 18, 2017, 03:29:28 pm »
In order to remove the notices, in the rows where you want to add error "@"

jerry singh

  • Newbie
  • *
  • Posts: 25
Re: Most Viewed Ads
« Reply #156 on: September 29, 2017, 08:53:28 am »
hello developers,

please let me know,
how to make make it possible for displaying popular ads result based on subdomain.

i have integrated subdomain, like- city.mydomain.com
but instead of fetching category from city side, its reflecting ads based on main domain.

how it will be possible to show popular ads based on subdomain..(city)


Code: [Select]
// function for displaying text on the Item page
function popular_ads_start() {
 
$num_ads = popular_ads_num_ads(); // SETS HOW MANY POPULAR ADS TO DISPLAY
 
$conn = getConnection();
$results=$conn->osc_dbFetchResults("SELECT fk_i_item_id, i_num_views FROM %st_item_stats ORDER BY fk_i_item_id ASC", DB_TABLE_PREFIX);

if(count($results)>0){
 
foreach($results as $result) {
@$view_count[$result['fk_i_item_id']] += @$result['i_num_views']; // Add-up all item views stored in database
}

arsort($view_count); // sorts array by highest number of item views first
 
foreach($view_count as $item_id=>$views) {
$result=$conn->osc_dbFetchResult("SELECT fk_i_user_id, fk_i_category_id, dt_pub_date, dt_mod_date, f_price, b_active, i_price, fk_c_currency_code, b_premium, s_secret,s_contact_name FROM %st_item WHERE pk_i_id = %d", DB_TABLE_PREFIX, $item_id); //Get active status of item
$result1=$conn->osc_dbFetchResult("SELECT i_expiration_days FROM %st_category WHERE pk_i_id = %d", DB_TABLE_PREFIX, $result['fk_i_category_id']); //Get expiration days of category
$result2=$conn->osc_dbFetchResult("SELECT DATEDIFF('". date('Y-m-d H:i:s')."','". $result['dt_pub_date']."') as DiffDate"); //Get expiration days difference
$bactive=0;
  if($result1['i_expiration_days']==0 || $result2['DiffDate'] <=$result1['i_expiration_days']) {
$bactive=1;
}
 
//if($result['b_active']==1){ //if active...
if($bactive==1){ //if active...
//echo 'Item ID: '.$item_id.' Views: '.$views.'<br>'; // display only if item is active
@$index++;
 
// get description
   
//$desc=$conn->osc_dbFetchResult("SELECT fk_c_locale_code, s_title, s_description, s_what FROM %st_item_description WHERE fk_i_item_id = %d", DB_TABLE_PREFIX, $item_id);
 
$desc=$conn->osc_dbFetchResult("SELECT fk_c_locale_code, s_title, s_description FROM %st_item_description WHERE fk_i_item_id = %d", DB_TABLE_PREFIX, $item_id);
 
 
//Get active status of item
$location=$conn->osc_dbFetchResult("SELECT fk_c_country_code, s_country, fk_i_region_id, s_region, fk_i_city_id, s_city FROM %st_item_location WHERE fk_i_item_id = %d", DB_TABLE_PREFIX, $item_id); //Get active status of item
// store the data in an array...
@$item_array[] =   array('fk_i_user_id'=>$result['fk_i_user_id'],
'fk_i_category_id'=>$result['fk_i_category_id'],
'dt_pub_date'=>$result['dt_pub_date'],
'dt_mod_date'=>$result['dt_mode_date'],
'f_price'=>$result['f_price'],
's_contact_name'=>$result['s_contact_name'],
'fk_i_item_id'=>$item_id,
'pk_i_id'=>$item_id,
'b_active'=>$result['b_active'],
'i_price'=>$result['i_price'],
'fk_c_currency_code'=>$result['fk_c_currency_code'],
'b_premium'=>$result['b_premium'],
'fk_c_locale_code'=>$desc['fk_c_locale_code'],
's_title'=>$desc['s_title'],
's_description'=>$desc['s_description'],
's_what'=>$desc['s_what'],
'fk_c_country_code'=>$location['fk_c_country_code'],
's_country'=>$location['s_country'],
'fk_i_region_id'=>$location['fk_i_region_id'],
's_region'=>$location['s_region'],
'fk_i_city_id'=>$location['fk_i_city_id'],
's_city'=>$location['s_city'],
's_secret'=>$result['s_secret'],
'locale'=>array('en_US'=>array('fk_i_item_id'=>$item_id,
'fk_c_locale_code'=>$desc['fk_c_locale_code'],
's_title'=>$desc['s_title'],
's_description'=>$desc['s_description'],
's_what'=>$desc['s_what']
)
)
);
}
if($index>=$num_ads)
break; // limit number of ads to display
}
 
GLOBAL $stored_items;
$stored_items = View::newInstance()->_get('items') ; //save existing item array
View::newInstance()->_exportVariableToView('items', $item_array);
 
} else echo 'No Results.';
}

function popular_ads_end() {
GLOBAL $stored_items;
   View::newInstance()->_exportVariableToView('items', $stored_items); //restore original item array
}

« Last Edit: September 29, 2017, 08:57:56 am by jerry singh »