попробовал сегодня установить плагин популярные объявления публикую как поставить как на картинке:
Устанавливаете как обычно из админки, после установки плагина в админке его не видно. Чтобы отобразить плагин с популярными объявлениями код, к примеру в main.php, то в сайтбаре ищем строку
и сразу после кода вставляем этот код
меняем в соответствие своей темы 'astrachan'
И еще в заключении подправляем стиль для цены что выделено зеленым, для этого в style.css добавляем этот код его можно добавить в конец стилей и редактировать под себя.
И еще в заключение чтобы плагин выводил объявления только активные, а не просроченные объявления нужно в файле index.php плагина найти код
и заменить его на этот
Теперь будут отображаться все активные по популярности объявления
скачать плагин прилагаю
Устанавливаете как обычно из админки, после установки плагина в админке его не видно. Чтобы отобразить плагин с популярными объявлениями код, к примеру в main.php, то в сайтбаре ищем строку
PHP:
<div class="box location">
Код:
<?php popular_ads_start(); ?>
<div class="pop_ads">
<h1><strong><?php _e('Популярные объявления', 'astrachan') ; ?></strong></h1>
<?php if( osc_count_items() == 0) { ?>
<p class="empty"><?php _e('Нет объявлений', 'astrachan') ; ?></p>
<?php } else { ?>
<table border="0" cellspacing="0">
<tbody>
<?php $class = "even"; ?>
<?php while ( osc_has_items() ) { ?>
<tr class="<?php echo $class. (osc_item_is_premium()?" premium":"") ; ?>">
<?php if( osc_images_enabled_at_items() ) { ?>
<td class="photo">
<?php if( osc_item_is_premium() ){ ?>
<div id="premium_img"></div>
<?php }?>
<?php if( osc_count_item_resources() ) { ?>
<a href="<?php echo osc_item_url() ; ?>">
<img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="75" height="56" title="" alt="" />
</a>
<?php } else { ?>
<a href="<?php echo osc_item_url() ; ?>">
<img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" alt="" title=""/>
</a>
<?php } ?>
</td>
<?php } ?>
<td class="text">
<p class="price1"><?php if( osc_price_enabled_at_items() ) echo osc_item_formated_price() ; ?></p>
<a href="<?php echo osc_item_url() ; ?>"><?php echo osc_item_title() ; ?></a>
<?php echo "(".osc_item_views()." просмотров)"; ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php if( osc_count_latest_items() == osc_max_latest_items() ) { ?>
<p class="see_more_link"><a href="<?php echo osc_search_show_all_url();?>"><strong><?php _e("Все", 'astrachan'); ?> »</strong></a></p>
<?php } ?>
<?php } ?>
</div>
<?php popular_ads_end(); ?>
</div>
И еще в заключении подправляем стиль для цены что выделено зеленым, для этого в style.css добавляем этот код его можно добавить в конец стилей и редактировать под себя.
Код:
p.price1 {background: #008000; color: #FFF; float:left; font:bold 14px Arial,Helvetica,sans-serif; padding:2px 4px 4px; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; -moz-box-shadow: 4px 3px 4px #AAA;-webkit-box-shadow: 4px 3px 4px #AAA; box-shadow: 4px 3px 4px #AAA; width: 100px;}
И еще в заключение чтобы плагин выводил объявления только активные, а не просроченные объявления нужно в файле index.php плагина найти код
PHP:
// 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 FROM %st_item WHERE pk_i_id = %d", DB_TABLE_PREFIX, $item_id); //Get active status of item
if($result['b_active']==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 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'],
'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'],
'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('item') ; //save existing item array
View::newInstance()->_exportVariableToView('items', $item_array);
} else echo 'No Results.';
}
и заменить его на этот
Код:
// 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.';
}
скачать плагин прилагаю