Ecommerce editing product list block

Permalink 1 user found helpful
In need of a bit of assistance from you php gurus out there. I am looking for a solution to this and hopefully it is a relatively easy one. I currently display 7 rows of 3 products each on my main page (so 21 items per page) and would like to throw in a google ad or other advertisement block smack dab in the middle of each page. In other words, the fourth row down, second item over would just be an advertisement block. Is there an easy way to accomplish this? I am not very good at php coding, but have been getting better and am comfortable editing and overriding files when needed. Thanks in advance!

 
yunotakemymoney replied on at Permalink Reply
surely someone has an idea of how to do this? I don't want this to get lost in the fray of new posts!
andrewsturm replied on at Permalink Reply
First off, you'll have to display 20 items instead of 21 because one of 'em will be your ad.

Off the top of my head: I would count the index of the loop(for each) and when you reach ..uh 11, insert the google ad.

$gridIdex = 1;
$gAdIndex = 11;
print('<div class="gridWithGoogleAd">');
for each($tile in $grid){
  if($gridIndex = $gAdIndex){
     print('<div id="googleAd">');
        print($googleAd);
     print('</div><!-- END googleAd -->');
  }else{
     //Concrete may already have divs, wrap 'em anyway
     print('<div class="tileGrid" id="tileGridIndex' . $gridIndex . '" >');
       print($tile);
     print('</div> <!-- END tileGrid  -->);
  }
$gridIndex +=1;

$googleAd - is the code given by google for your ads.
$grid - would be the var that has all of your site's items in it.
$tile - is just each item in the grid.

I haven't tested this AND I don't know which add-on you're using to make the grid. This is just a general format.

If you post some code from what you're "overriding" at I may be able to help.

...
yunotakemymoney replied on at Permalink Reply
Thanks for the help so far. As far as I know, this is the code I will need to edit to throw in the google ad. This is the view.php file from the product list block
<?php   
defined('C5_EXECUTE') or die(_("Access Denied."));  
global $c;
$uh = Loader::helper('urls', 'core_commerce');
$im = Loader::helper('image');
if ($options['show_search_form']) {
   $this->inc('view_search_form.php', array( 'c'=>$c, 'b'=>$b, 'controller'=>$controller,'block_args'=>$block_args ) );
}
?>
<?php   if ($options['show_products'] || $_REQUEST['search'] == '1') { ?>
   <?php  
   $nh = Loader::helper('navigation');
   $productList = $this->controller->getRequestedSearchResults();
   if ($options['hide_sold_out']) {
      $productList->displayOnlyProductsWithInventory();
yunotakemymoney replied on at Permalink Reply
trying to bump this up to get some more assistance with this.