【问题标题】:Issue with Yii infinite scroll and Google AdSenseYii 无限滚动和 Google AdSense 的问题
【发布时间】:2014-03-17 06:18:45
【问题描述】:

我已经在 Yii 框架中实现了这个项目。我对 Google 广告和 Yii 无限滚动(即延迟加载)有疑问。我有问题。我将代码从站点控制器发送到索引页面以进行无限滚动,页面大小为 10。我想在页面中显示 Google 广告 5。我的索引页面包含食谱详细信息,即带有详细信息的图像。 我想每 10 张图片展示一次 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++;
?> 

【问题讨论】:

  • 显示空白图像的屏幕截图。它无法显示。广告应该每 10 张图片展示一次,并且从控制器 10 获取的页面(pageSize=10)

标签: javascript php yii adsense endlessscroll


【解决方案1】:

不,您不能。 AdSense 允许每页 3 个广告单元,无论多长时间 一页是。因此无限滚动页面是相当不合适的 对于 AdSense。1

等等!但是有些网站会这样做,例如 mashablepinterest

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

常规发布商不能这样做2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多