Advertisement:

Author Topic: [TIP] Ads Between Listings  (Read 24402 times)

nootkan

  • Sr. Member
  • ****
  • Posts: 259
Re: [TIP] Ads Between Listings
« Reply #15 on: July 29, 2014, 08:44:52 pm »
Will this work for any banner ad setup or is it just for adsense banners?

cartagena68

  • issues
  • Hero Member
  • *
  • Posts: 1190
Re: [TIP] Ads Between Listings
« Reply #16 on: July 29, 2014, 08:51:43 pm »
you can use it with different banners

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #17 on: July 29, 2014, 09:58:35 pm »
In fact, you can put there whatever you want. Hey, why not a premium ad? ???

Regards

fog

  • Hero Member
  • *****
  • Posts: 1062
Re: [TIP] Ads Between Listings
« Reply #18 on: July 30, 2014, 12:17:37 am »
Hi teseo,

I can display only the banner in the middle of the list, given that my results are shown 10 ads per page. Where will the banner, after the first 5 ads, or somewhere after refresh page, like random position? (the image of this first post I see 2 banners).
I dont test it on my theme, I just need this response for start.

Thanks for clarify

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #19 on: July 30, 2014, 02:33:18 am »
This code is programmed to show 1 banner in the middle:

Code: [Select]
$adSense_middle_pos = ceil(osc_count_items()/2);
but it may be programmed the way you want:

$adSense_middle_pos = osc_count_items()-1; // 1 banner just before the last ad

$adSense_middle_pos = rand(1, 10); // 1 banner randomly positioned

Regarding the number of banners shown, this line:

Code: [Select]
if ($ad_counter == $adSense_middle_pos && Params::getParam('ShowAs' != 'gallery')) {
if ($ad_counter == 3 || $ad_counter == 6 && Params::getParam('ShowAs' != 'gallery')) { // 2 banners in 3rd and 6th positions

If you want to keep everything relative to the total number of ads shown, use operations instead of fixed numbers:

if ($ad_counter == round(osc_count_items()/3) || round((osc_count_items()/3)*2) && Params::getParam('ShowAs' != 'gallery')) { // 2 banners in 3rd and 6th positions [if your have 10 items] (relative, banner every 1/3 of items shown)

Anyway, beware: Last page of results probably won't have the maximum of items per page, but less. So keep your formula in a way that won't look ugly in these last pages (or find a way to detect this circumstance and include code to change behaviour when this happens).

Regards
« Last Edit: July 30, 2014, 02:43:56 am by teseo »

fog

  • Hero Member
  • *****
  • Posts: 1062
Re: [TIP] Ads Between Listings
« Reply #20 on: July 30, 2014, 03:16:06 am »
Wow, this is amazing. Many thanks for all the light and dispensed code.  :)

Regards

Heartcore

  • Newbie
  • *
  • Posts: 38
Re: [TIP] Ads Between Listings
« Reply #21 on: August 07, 2014, 09:27:27 pm »
wow...i love this tutt...

can you show me how to add this to this theme?

Symnel - Free Responsive Osclass Theme


Thanks in advance!

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #22 on: August 07, 2014, 10:17:05 pm »
Ask to the theme developer, all the needed info is here in this thread and who knows, maybe he might want to add this feature to his theme. ;)

Regards

Heartcore

  • Newbie
  • *
  • Posts: 38
Re: [TIP] Ads Between Listings
« Reply #23 on: August 08, 2014, 08:55:27 am »
ok then...

Thanks...

Omarcito

  • Full Member
  • ***
  • Posts: 138
Re: [TIP] Ads Between Listings
« Reply #24 on: August 17, 2014, 10:47:44 pm »
Hi :
Sorry for my English.
I did not understand that changes do to put a rotating banner ads instead of Ad Sense.
They could explain.
Thank you very much.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #25 on: August 17, 2014, 11:55:44 pm »
Hi,

This:

// [Specific AdSense code here]

replace it with the code for your desired element (AdSense code, banner code, a photo of your favorite actress... :D, whatever).

Regards

user88

  • Jr. Member
  • **
  • Posts: 81
Re: [TIP] Ads Between Listings
« Reply #26 on: October 15, 2014, 04:55:43 am »
Hi, I added code, but banner not showing. Can anyone help me? I'm using Celio Theme (like Infinity theme) This is my code:

Code: [Select]
<?php
$loopClass 
'';
$type 'items';
if(
View::newInstance()->_exists('listType')){
    
$type View::newInstance()->_get('listType'); 
}
if(
View::newInstance()->_exists('listClass')){
    
$loopClass View::newInstance()->_get('listClass'); 
}
?>

<ul class="listing-card-list <?php echo $loopClass?>" id="listing-card-list">
    <?php
        $i 
0;

        if(
$type == 'latestItems'){
            while ( 
osc_has_latest_items() ) {
                
$class '';
                if(
$i%== 0){
                    
$class 'first';
                }
                
celio_draw_item($class);
                
$i  ;
            }
        } elseif(
$type == 'premiums'){
            while ( 
osc_has_premiums() ) {
                    
$class '';
                    if(
$i%== 0){
                        
$class 'first';
                    }
                    
celio_draw_item($class,false,true);
                    
$i  ;
                    if(
$i == 3){
                        break;
                    }
                
$i  ;
            }
        } else {
$adSense_middle_pos ceil(osc_count_items()/2);
            
$ad_counter 0;

            while(
osc_has_items()) {
                
$i  ;
                
$class false;
                if(
$i%== 0){
                    
$class 'last';
                }
                
$admin false;
                if(
View::newInstance()->_exists("listAdmin")){
                    
$admin true;
                }

                
celio_draw_item($class,$admin);

$ad_counter  ;
                if (
$ad_counter == $adSense_middle_pos && Params::getParam('ShowAs' != 'gallery')) {
                    
//AdSense middle ?>

                    <tr><td colspan="2">

                        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                                <!-- cbay - middle - 468x60 -->
                                <ins class="adsbygoogle"
                                     style="display:inline-block;width:468px;height:60px"
                                     data-ad-client="ca-pub-8515941945820433"
                                     data-ad-slot="8344279103"></ins>
                                <script>
                                (adsbygoogle = window.adsbygoogle || []).push({});
                            </script>

                    </td></tr>
                    <?php }
          }
        }
    
?>

</ul>

keerthi

  • Hero Member
  • *****
  • Posts: 505
Re: [TIP] Ads Between Listings
« Reply #27 on: October 15, 2014, 11:50:22 am »
whats your site.

user88

  • Jr. Member
  • **
  • Posts: 81
Re: [TIP] Ads Between Listings
« Reply #28 on: October 15, 2014, 01:25:57 pm »

user88

  • Jr. Member
  • **
  • Posts: 81
Re: [TIP] Ads Between Listings
« Reply #29 on: October 15, 2014, 04:16:07 pm »
so?