۱۳۹۳-۱۰-۰۶، ۰۲:۳۷ ب.ظ
سلام
با اجازه ادمین مجترم میخوام آموزش نمایش آگهی ها بصورت راندم یا اتفاقی در صفجه اصلی رو بزارم (منبع سایت اصلی : osclass)
(1) فایل functions.php را باز کرده و کد زیر را در انتهای کدهای فایل اضافه کنید:
(2) در فایل main.php خط زیر را پیدا کنید:
و با این خط عوض کنید:
تمام شد .
با اجازه ادمین مجترم میخوام آموزش نمایش آگهی ها بصورت راندم یا اتفاقی در صفجه اصلی رو بزارم (منبع سایت اصلی : osclass)
(1) فایل functions.php را باز کرده و کد زیر را در انتهای کدهای فایل اضافه کنید:
کد:
<?php
function cust_getRandomItems($numItems = 10, $category = array(), $withPicture = false)
{
$mSearch = Search::newInstance();
$mSearch->dao->select(DB_TABLE_PREFIX.'t_item.* ');
// from + tables
$mSearch->dao->from( DB_TABLE_PREFIX.'t_item use index (PRIMARY)' );
if($withPicture) {
$mSearch->dao->from(sprintf('%st_item_resource', DB_TABLE_PREFIX));
$mSearch->dao->where(sprintf("%st_item_resource.s_content_type LIKE '%%image%%' AND %st_item.pk_i_id = %st_item_resource.fk_i_item_id", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX));
}
// where
$whe = DB_TABLE_PREFIX.'t_item.b_active = 1 AND ';
$whe .= DB_TABLE_PREFIX.'t_item.b_enabled = 1 AND ';
$whe .= DB_TABLE_PREFIX.'t_item.b_spam = 0 AND ';
$whe .= '('.DB_TABLE_PREFIX.'t_item.b_premium = 1 || '.DB_TABLE_PREFIX.'t_item.dt_expiration >= \''. date('Y-m-d H:i:s').'\') ';
// $whe .= 'AND '.DB_TABLE_PREFIX.'t_category.b_enabled = 1 ';
if( is_array($category) && (count($category) > 0) ) {
$listCategories = implode(',', $category );
$whe .= ' AND '.DB_TABLE_PREFIX.'t_item.fk_i_category_id IN ('.$listCategories.') ';
}
$mSearch->dao->where( $whe );
// group by & order & limit
$mSearch->dao->groupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
$mSearch->dao->orderBy('RAND()');
$mSearch->dao->limit($numItems);
$rs = $mSearch->dao->get();
if($rs === false){
return array();
}
if( $rs->numRows() == 0 ) {
return array();
}
$items = $rs->result();
return Item::newInstance()->extendData($items);
}
?>
(2) در فایل main.php خط زیر را پیدا کنید:
کد:
if( osc_count_latest_items() == 0) { ?>
و با این خط عوض کنید:
کد:
View::newInstance()->_exportVariableToView('latestItems', cust_getRandomItems());
if( osc_count_latest_items() == 0) { ?>
تمام شد .