0

I have implemented the project in Yii framework. I have issue with Google ads and Yii infinite scroll ie (lazy loading). I have problem with it. I sending the code from site controller to index page for infinite scroll which page size is 10. I want to be show the Google ads 5 in a page. My index page contains recipe details i.e. image with details. I want to be show the Google ads every 10 images one ad should be displayed. If I remove the controller code (i.e. I sending the page size code). Five Google ads are working fine. The issue is my index page is container large size, i.e. it could be more than 300 images. so that I showing these 10 by 10 using infinite scroll.

I added my code here; please suggest my how to overcome this issue:

My controller code is:

$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,
));

My index page is:

<?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++;
?> 
Jay kumar
  • 277
  • 2
  • 13
  • screen shot showing empty images. it could not be show. the ads should be shown every 10 images and also pages fetching from controller 10(pageSize=10) – Jay kumar Mar 17 '14 at 06:28

1 Answers1

0

No, you can't. AdSense allows 3 ad units per page, no matter how long a page is. Therefore an infinite scrolling page is rather unsuitable for AdSense.1

Wait! But there are sites doing this, like mashable and pinterest!

Mashable is a premium publisher with their own set of rules, given to them directly by an AdSense account rep.

Regular publishers can't do that.2

Samuel Liew
  • 68,352
  • 105
  • 140
  • 225