Zach2k wrote:Greetings Monoray team,
I would like to report a bug in the advertisement module: (I have purchased a pro license)
if you have 2 or more ads (same position or different) the views counter updates on the latest ad ONLY, so if you have 3 ads on the same page and every-time you refresh only 1 ad will get more views.
I tested this on your demo and the same results, once you add the 2nd add, the 1st one stop updating views.
would you kindly post a fix.
Thank you
if ($content && is_array($content)) {
$this->publishAssets();
$pos1 = $pos2 = $pos3 = $pos4 = $pos5 = $pos6 = array();
foreach ($content as $key => $item) {
if ($item['position'] == 'pos1') {
$pos1[] = $item;
}
if ($item['position'] == 'pos2') {
$pos2[] = $item;
}
if ($item['position'] == 'pos3') {
$pos3[] = $item;
}
if ($item['position'] == 'pos4') {
$pos4[] = $item;
}
if ($item['position'] == 'pos5') {
$pos5[] = $item;
}
if ($item['position'] == 'pos6') {
$pos6[] = $item;
}
}
Yii::app()->controller->advertPos1 = $pos1;
Yii::app()->controller->advertPos2 = $pos2;
Yii::app()->controller->advertPos3 = $pos3;
Yii::app()->controller->advertPos4 = $pos4;
Yii::app()->controller->advertPos5 = $pos5;
Yii::app()->controller->advertPos6 = $pos6;
// set count
if ((int)$item['id']) {
Advert::model()->updateCounters(
array('views' => 1), "id = :id", array(':id' => (int)$item['id'])
);
}
unset($pos1, $pos2, $pos3, $pos4, $pos5, $pos6);
$ids = [];
$pos1 = $pos2 = $pos3 = $pos4 = $pos5 = $pos6 = array();
foreach ($content as $key => $item) {
if ($item['position'] == 'pos1') {
$pos1[] = $item;
}
if ($item['position'] == 'pos2') {
$pos2[] = $item;
}
if ($item['position'] == 'pos3') {
$pos3[] = $item;
}
if ($item['position'] == 'pos4') {
$pos4[] = $item;
}
if ($item['position'] == 'pos5') {
$pos5[] = $item;
}
if ($item['position'] == 'pos6') {
$pos6[] = $item;
}
$ids[] = $item['id'];
}
Yii::app()->controller->advertPos1 = $pos1;
Yii::app()->controller->advertPos2 = $pos2;
Yii::app()->controller->advertPos3 = $pos3;
Yii::app()->controller->advertPos4 = $pos4;
Yii::app()->controller->advertPos5 = $pos5;
Yii::app()->controller->advertPos6 = $pos6;
// set count
if ($ids) {
$criteria = new CDbCriteria();
$criteria->compare('id', $ids);
Advert::model()->updateCounters(
array('views' => 1), $criteria
);
}
Users browsing this forum: No registered users and 4 guests