Insert ads in category view, every five items

More
6 months 1 week ago #71317 by charlynancy
Hi,
i am working on the new format of adsense adds.
Since 1 year, it's possible to add "Infeed Ad"
you can have several times one ad in a page.
So i am trying to add the code ad every 5 items in my page.

Google explain how to implement this function with the code below on this page :
Posts[] posts;
count Var = 1; // Si votre code ne comprend pas de compteur, veuillez en définir un.
While (count < posts.length) // Ajoutez 1 à la valeur de "count" jusqu'à atteindre le dernier élément dans la base de données.
{

   If (count%3=0) // Si la valeur de "count" est égale à 3, 6 ou 9, insérez l'annonce.
   {
   <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
   </script>
   <ins class="adsbygoogle" style="display:block"
   data-ad-format="fluid"
   data-ad-client="ca-pub-1234567891234567"
   data-ad-slot="1234567890"></ins>
   <script>
   (adsbygoogle = window.adsbygoogle || []).push({});
   </script>
   }

   <h3>{{ post.title }}</h3> // Pour toutes les valeurs de "count", insérez le titre du bloc de contenu.
   <p>{{ post.body }}<p> // Insérez le corps du bloc de contenu.
   <img src="{{ post.thumbnail}}"> // Insérez l'image du bloc de contenu.

}

i use the template " Tab / slider item placement"
i tried to add the code in "category_items.php" file.
But i can't understand how to implement this with php foreach function?

Please Log in or Create an account to join the conversation.

More
6 months 1 week ago - 6 months 1 week ago #71318 by ggppdk
Hello

To add at position 0 and at position 5, etc

Find:
<?php
foreach ($items as $i => $item) :

and exactly on the next line try to add this
	if ($i % 5 === 0) 
	{
	?>

<!-- tab start -->
<?php echo '<'.$mainAreaTag; ?> id="tablist_item_<?php echo $i; ?>" class="group" <?php echo $microdata_itemtype_code; ?>>
	<h3 class="tabberheading"><?php echo StringHelper::substr($item->title, 0, 20); ?></h3><!-- tab title -->
		
		<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
		</script>

		<ins class="adsbygoogle" style="display:block"
		data-ad-format="fluid"
		data-ad-client="ca-pub-1234567891234567"
		data-ad-slot="1234567890"></ins>

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

<?php echo '</'.$mainAreaTag.'>'; ?>
<!-- tab end -->


	<?php
	}


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
Last edit: 6 months 1 week ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
6 months 1 week ago - 6 months 1 week ago #71334 by charlynancy
Hello Georgios,
Thank you so much for your help.

Your solution is perfect as usually.

In my case, here is the code i have inserted :
foreach ($items as $i => $item) :


//jca pub infeed
	if (($i == 5) || ($i == 9))
	{
	?>
	
<?php echo '<div id="cataloglist_item_'.$i.'" class="catalogitem group rt-block rt-light-block  nopaddingall shadow10 rounded">'; ?>	
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
.....
</script>

</div>	

	<?php
	}
//jca pub infeed

In fact i wanted to insert 1 pub after 5 items (not before the first)
and an other one each 5 items (because i have implemented infinite scrolling, perhaps you remember about that and about my temporarely solution )

I think your solution will be very helpful because we see more and more sites that use "infeed" ads for the mobiles display.

Thank you very much again.
Last edit: 6 months 1 week ago by charlynancy.

Please Log in or Create an account to join the conversation.

More
6 months 1 week ago #71335 by ggppdk
Hello

thanks for feedback

indeed a new configuration option to insert ads every N items
would be useful to a considerable number of our users

github.com/FLEXIcontent/flexicontent-cck/issues/825


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.