You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
756 B

6 years ago
<?php
/**
* Created by Error202
* Date: 22.08.2018
*/
use yii\helpers\Html;
use yii\helpers\Url;
6 years ago
/**
* @var $this \yii\web\View
* @var $banner \common\modules\banners\entities\Banner;
*/
$banner_id = 'banner_' . $banner->id;
$view_url = Url::to(['/banner/view']);
$click_url = Url::to(['/banner/click']);
$js = <<<JS
$("#{$banner_id}").on('click', function(){
$.ajax({
method: "POST",
url: "{$click_url}",
data: { id: "{$banner->id}" }
});
});
$.ajax({
method: "POST",
url: "{$view_url}",
data: { id: "{$banner->id}" }
});
JS;
$this->registerJs($js, $this::POS_READY);
6 years ago
?>
<?= Html::a(Html::img('@static/origin/banners/' . $banner->image), $banner->url, [
'target' => $banner->target,
'id' => $banner_id,
6 years ago
]) ?>