繁体   English   中英

Yii无限滚动和Google AdSense问题

[英]Issue with Yii infinite scroll and Google AdSense

我已经在Yii框架中实施了该项目。 我在使用Google广告和Yii无限滚动(即延迟加载)时遇到了问题。 我有问题。 我将代码从站点控制器发送到索引页面,以进行无限滚动,页面大小为10。我想在页面中展示Google广告5。 我的索引页面包含配方细节,即带有细节的图像。 我希望每10张图片向Google显示一次广告。 如果删除控制器代码(即发送页面大小代码)。 五个Google广告运行正常。 问题是我的索引页是容器大的,即可能超过300张图像。 这样我就可以使用无限滚动显示这10 x 10。

我在这里添加了代码; 请建议我如何克服这个问题:

我的控制器代码是:

$criteria = new CDbCriteria;
$total = Recipe::model()->count();

$pages = new CPagination($total);
$pages->pageSize = 10;
$pages->applyLimit($criteria);

$posts = Recipe::model()->findAll($criteria);

$this->render('index', array(
    'posts' => $posts,
    'pages' => $pages,
));

我的索引页面是:

<?php $post_counter=0; $addnum=1; foreach($posts as $receipe): ?>

<div class="post">
<?php
$rec_img=$receipe['recipe_small_image'];
$recipe_id=$receipe['recipe_id'];
$rec_name=$receipe['name'];
$calorie_count=$receipe['calorie_count'];

$type=$receipe['type'];
$rec_course=$receipe['course_id'];
$cus_name=$receipe['cuisinename'];

$post_counter++;

if(($post_counter=9 && $addnum<=4)) { 
    $post_counter=1;
?>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-11 wrdLatest" id="imgcontent_rand_recipe">
    <script async src="xxxxxxxxxxxxx"></script>

    <ins class="adsbygoogle kraftmonsterresponsive"
        style="display:xxxxxxxxxx"
        data-ad-client="xxxxxxxxxx"
        data-ad-slot="xxxxxxxxxxx"></ins>

    <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
</div>   

<?php }
$addnum= $addnum+1;
$post_counter++;
?> 

不,你不能。 无论页面有多长,AdSense都允许每页3个广告单元。 因此,无限滚动页面非常不适合AdSense。 1个

等待! 但是有些网站正在这样做,例如mashablepinterest

Mashable是具有自己的一套规则的高级发布者 ,由AdSense客户代表直接提供给他们。

普通出版商不能这样做 2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM