Osclass forums

Support forums => Tips, tricks, and tutorials => Topic started by: keerthi on June 20, 2014, 08:44:38 am

Title: [TIP] Ads Between Listings
Post by: keerthi on June 20, 2014, 08:44:38 am
Thanks to @teseo. None of the code below are mine.

This procedure will insert an AdSense ad in the middle of your site Ads list, it should put you on the right track if you want to show more:

Theme search-list.php or equivalent:

Code: [Select]
<?php // list regular ads
    
$adSense_middle_pos ceil(osc_count_items()/2);
    
$ad_counter 0;
    while(
osc_has_items()) { ?>


<tr // etc

// [Normal code here]

?>
</tr>

<?php $ad_counter++;
        if (
$ad_counter == $adSense_middle_pos) {
            
//AdSense middle ?>

        <tr><td colspan="2">

// [Specific AdSense code here]

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

        
$class = ($class == 'even') ? 'odd' 'even';
    } 
?>


The result will be something like as shown in the pic.
Title: Re: [TIP] Ads Between Listings
Post by: rahulk on June 20, 2014, 09:10:06 am
I am using minimalist theme(Modern), could you guide me step-by-step how to insert this code for adsense ads between listings.

Thanks
Title: Re: [TIP] Ads Between Listings
Post by: teseo on June 20, 2014, 11:36:56 am
Index by theme:

Bender (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99119/#msg99119)
Bootsnap-Classic (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg100452/#msg100452)
Flatter (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg120843/#msg120843) (Thanks, gnoe)
Infinity (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99740/#msg99740)
Minimalist (this post)
Modern (this post)
Osclass Wizards (https://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg157104/#msg157104)
Repurpose (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg120232/#msg120232)
Royal (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg113980/#msg113980)
Twitter (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg120232/#msg120232)

Possible variants (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg102038/#msg102038) (tutorial of sorts :D)

**************************


Hi,

Why, precissely I have used Minimalist 1.2 search-list.php for my example... :D But fine, I'll explain it step by step so it could be useful for other themes too:

1.-

Code: [Select]
// list regular ads
while(osc_has_items())
{

to:

Code: [Select]
// list regular ads
                        $adSense_middle_pos = ceil(osc_count_items()/2);
                        $ad_counter = 0;
while(osc_has_items())
{

2.-

Quote
<tr // etc

// [Normal code here]

?>
</tr>

This translates on vanilla Minimalist as:

Code: [Select]
<tr class="<?php echo $class?>">
<?php
if(osc_images_enabled_at_items())
{
?>

<td class="photo">
<?php
if(osc_count_item_resources())
{
?>

<a href="<?php echo osc_item_url(); ?>" class="image">
<img src="<?php echo osc_resource_thumbnail_url(); ?>" width="75" height="56" title="<?php echo osc_item_title(); ?>" alt="<?php echo osc_item_title(); ?>" />
<?php echo clb_minimalist_format_image_count(); ?>
</a>
<?php
}
else
{
?>

<img src="<?php echo osc_current_web_theme_url('images/no_photo.gif'); ?>" title="" alt="" />
<?php ?>
</td>
<?php
}
?>

<td class="text">
<h3>
<?php
echo clb_minimalist_format_list_title(osc_item_title(), osc_item_url(), falsetrue);
?>

</h3>
<p>
<strong>
<?php
if(osc_price_enabled_at_items())
{
echo osc_item_formated_price();
?>
- <?php
}
echo osc_item_city();
?>
(<?php echo osc_item_region(); ?>) - <?php echo osc_format_date(osc_item_pub_date());
?>

</strong>
</p>
<p><?php echo osc_highlight(strip_tags(osc_item_description())); ?></p>
</td>
</tr>

You need to identify where the table row (<tr>) for each ad starts and finishes (just for reference, you need to leave this block untouched).

3.- Now replace:

Code: [Select]
<?php
$class = ($class == 'even') ? 'odd' 'even';
}
?>

with:

Code: [Select]
<?php 
        $ad_counter
++;
        if (
$ad_counter == $adSense_middle_pos) {
            
//AdSense middle ?>

        <tr><td colspan="2">

// [Specific AdSense code here]

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

        
$class = ($class == 'even') ? 'odd' 'even';
    } 
?>

Regards
Title: Re: [TIP] Ads Between Listings
Post by: Media DMJ on June 20, 2014, 12:01:30 pm
 8)
Title: Re: [TIP] Ads Between Listings
Post by: teseo on June 20, 2014, 12:13:00 pm
***UPDATED***

For Bender you need to modify oc-content/themes/bender/loop.php

This block at the end of the script:

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

                bender_draw_item($class,$admin);

Replace it with:

Code: [Select]
        $adSense_middle_pos = ceil(osc_count_items()/2);
        $ad_counter = 0;
   
        while(osc_has_items()) {
            $i++;
            $class = false;
            if($i%4 == 0){
                $class = 'last';
            }
            $admin = false;
            if(View::newInstance()->_exists("listAdmin")){
                $admin = true;
            }
       
            bender_draw_item($class,$admin);
       
            $ad_counter++;
            if ($ad_counter == $adSense_middle_pos && bender_show_as() == 'list') {
            //AdSense middle ?>
                <li class="listing-card">
           
                    // [Specific AdSense code here]
           
                </li>
            <?php }

Important note: I've programmed this in a way that will only work for List View, to insert a single "fake regular ad" on Gallery View would scramble the symmetry of the grid layout. :( You'd need to insert 4 AdSenses to keep things pretty...  ???

Regards
Title: Re: [TIP] Ads Between Listings
Post by: rahulk on June 21, 2014, 09:07:56 am
Thanks teseo, you are dependable!
Title: Re: [TIP] Ads Between Listings
Post by: Hambitz Classified on June 27, 2014, 07:05:31 pm
Hi can anyone help me with this  using infinity theme?
Title: Re: [TIP] Ads Between Listings
Post by: keerthi on June 27, 2014, 09:27:41 pm
follow teseos advice. infinity theme is based on bender.
Title: Re: [TIP] Ads Between Listings
Post by: Hambitz Classified on June 27, 2014, 10:36:04 pm
Hi Sorry still having problems

adsence doesn't show for me

here is my stock  loop.php
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';
                }
                
infinity_draw_item($class);
                
$i  ;
            }
        } elseif(
$type == 'premiums'){
            while ( 
osc_has_premiums() ) {
                    
$class '';
                    if(
$i%== 0){
                        
$class 'first';
                    }
                    
infinity_draw_item($class,false,true);
                    
$i  ;
                    if(
$i == 3){
                        break;
                    }
                
$i  ;
            }
        } else {
            while(
osc_has_items()) {
                
$i  ;
                
$class false;
                if(
$i%== 0){
                    
$class 'last';
                }
                
$admin false;
                if(
View::newInstance()->_exists("listAdmin")){
                    
$admin true;
                }

                
infinity_draw_item($class,$admin);
          }
        }
    
?>

</ul>
  can somebody please  help

here is the file with my changes

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';
                }
                
infinity_draw_item($class);
                
$i  ;
            }
        } elseif(
$type == 'premiums'){
            while ( 
osc_has_premiums() ) {
                    
$class '';
                    if(
$i%== 0){
                        
$class 'first';
                    }
                    
infinity_draw_item($class,false,true);
                    
$i  ;
                    if(
$i == 3){
                        break;
                    }
                
$i  ;
            }
        } else {
            while(
osc_has_items()) {
                
$i  ;
                
$class false;
                if(
$i%== 0){
                    
$class 'last';
                }
                
$admin false;
                if(
View::newInstance()->_exists("listAdmin")){
                    
$admin true;
                }

                
infinity_draw_item($class,$admin);
          }
        }
    
?>

</ul>
     } else {
            $adSense_middle_pos = ceil(osc_count_items()/2);
            $ad_counter = 0;

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

                infinity_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>
<!-- myads bottom -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-9669950371192794"
     data-ad-slot="4003719862"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>   

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

</ul>


what am I doing wrong? :-[
Title: Re: [TIP] Ads Between Listings
Post by: teseo on June 27, 2014, 11:30:29 pm
Hi,

You didn't pay enough attention. Take another look at my last post for Bender, you have in your theme a block of code virtually identical to what needs to be replaced, the only difference is in this line:

bender_draw_item($class,$admin); ==> infinity_draw_item($class,$admin);

 ;)

Regards
Title: Re: [TIP] Ads Between Listings
Post by: Hambitz Classified on June 28, 2014, 02:37:06 am
Hi Teseo,

either Im blind or stupid or both but I have changed that line   and still nothing shows..   long day lol :-[
Title: Re: [TIP] Ads Between Listings
Post by: teseo on June 28, 2014, 03:02:21 am
***UPDATED***

For Infinity you need to modify oc-content/themes/infinity/loop.php

This block:

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

                infinity_draw_item($class,$admin);
 
 

Replace it with:

Code: [Select]
        $adSense_middle_pos = ceil(osc_count_items()/2);
        $ad_counter = 0;
   
        while(osc_has_items()) {
            $i++;
            $class = false;
            if($i%4 == 0){
                $class = 'last';
            }
            $admin = false;
            if(View::newInstance()->_exists("listAdmin")){
                $admin = true;
            }
       
            infinity_draw_item($class,$admin);
       
            $ad_counter++;
            if ($ad_counter == $adSense_middle_pos && infinity_show_as() == 'list') {
            //AdSense middle ?>
                <li class="listing-card">
           
                    // [Specific AdSense code here]
           
                </li>
            <?php 

Regards
Title: Re: [TIP] Ads Between Listings
Post by: creat15 on July 08, 2014, 04:19:35 pm
Hi :) teseo i follow your tutorial, but banner ads not show on search_list.php

this is my code search_list.php i using classic theme


Code: [Select]
        <?php while(osc_has_premiums()) { ?>
            <div class="item-list well2">
                <div class="text">
                <p class="featured" >Premium Listing | $ <?php if (osc_price_enabled_at_items()) {echo osc_premium_formated_price() . " ";}?></p>
                <h3>
                <a href="<?php echo osc_premium_url();?>"><?php echo osc_premium_title();?></a>
                </h3>
                <p><strong><?php if (osc_premium_city() != '') {echo osc_premium_city();}if (osc_premium_region() != '') {echo ' (' osc_premium_region() . ')';}echo ' - ' osc_format_date(osc_premium_pub_date()); echo ' - Total Views: '.ItemStats::newInstance()->getViews(osc_premium_id()); ?> </strong> - <strong>expired: <?php echo time_diff1(osc_premium_pub_date());?></strong></p>
                <p><?php echo osc_highlight(strip_tags(osc_premium_description()));?></p>
                <p><a title="" href="<?php echo osc_premium_url();?>" class="btn pull-right">See More... <strong>&raquo;</strong></a></p>
                </div>
                <?php if( osc_images_enabled_at_items() ) { ?>

                 <div class="photo">
                     <?php if(osc_count_premium_resources()) { ?>
                        <a href="<?php echo osc_premium_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="125px" height="125px" title="" alt="" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" width="125px" height="125px" title="" alt="" title="" alt="" />
                    <?php ?>
                 </div>
                 <?php ?>
             </div>
        <?php ?>
<?php ?>

        <?php while(osc_has_items()) { ?>
<?php if(!osc_item_is_premium()) { ?>
             <div class="item-list well">
               <div class="text">
                <p class="price">$ <?php if (osc_price_enabled_at_items()) {echo osc_item_formated_price();?></p>
                <h3><a href="<?php echo osc_item_url();?>"><?php echo osc_item_title();}?></a></h3>
                <p><strong><?php if (osc_item_city() != '') {echo osc_item_city();}if (osc_item_region() != '') {echo ' (' osc_item_region() . ')';}echo ' - ' osc_format_date(osc_item_pub_date()); echo ' - Total Views: '.ItemStats::newInstance()->getViews(osc_item_id()); ?> </strong> - <strong>expired : <?php echo time_diff1(osc_item_pub_date());?></strong></p>
                <p><?php echo osc_highlight(strip_tags(osc_item_description()));?></p>
                <p><a title="" href="<?php echo osc_item_url() ; ?>" class="btn pull-right">See More... <strong>&raquo;</strong></a></p>
                </div>
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="photo">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="125px" height="125px" title="" alt="" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" width="125px" height="125px" title="" alt="" />
                    <?php ?>
                 </div>
                 <?php ?>

             </div>
<?php ?>
        <?php ?>

please help me  :-[

thanks before
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 08, 2014, 04:55:06 pm
Hi,

The element where each ad is wrapped on may vary from theme to theme, the key to adapt this code to your theme is here:

Quote
<?php $ad_counter++;
        if ($ad_counter == $adSense_middle_pos) {
            //AdSense middle ?>
        <tr><td colspan="2">

// [Specific AdSense code here]

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

Themes Modern, Minimalist, Bender and Infinity (already mentioned in this thread) and others use an HTML table, yours seems to use a div, so replace this block:

Code: [Select]
<?php while(osc_has_items()) { ?>
<?php if(!osc_item_is_premium()) { ?>
             <div class="item-list well">
               <div class="text">
                <p class="price">$ <?php if (osc_price_enabled_at_items()) {echo osc_item_formated_price();?></p>
                <h3><a href="<?php echo osc_item_url();?>"><?php echo osc_item_title();}?></a></h3>
                <p><strong><?php if (osc_item_city() != '') {echo osc_item_city();}if (osc_item_region() != '') {echo ' (' osc_item_region() . ')';}echo ' - ' osc_format_date(osc_item_pub_date()); echo ' - Total Views: '.ItemStats::newInstance()->getViews(osc_item_id()); ?> </strong> - <strong>expired : <?php echo time_diff1(osc_item_pub_date());?></strong></p>
                <p><?php echo osc_highlight(strip_tags(osc_item_description()));?></p>
                <p><a title="" href="<?php echo osc_item_url() ; ?>" class="btn pull-right">See More... <strong>&raquo;</strong></a></p>
                </div>
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="photo">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="125px" height="125px" title="" alt="" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" width="125px" height="125px" title="" alt="" />
                    <?php ?>
                 </div>
                 <?php ?>

             </div>
<?php ?>
        <?php ?>

with:

Code: [Select]
<?php 
    $adSense_middle_pos 
ceil(osc_count_items()/2);
    
$ad_counter 0;
    while(
osc_has_items()) { ?>

<?php if(!osc_item_is_premium()) { ?>
             <div class="item-list well">
               <div class="text">
                <p class="price">$ <?php if (osc_price_enabled_at_items()) {echo osc_item_formated_price();?></p>
                <h3><a href="<?php echo osc_item_url();?>"><?php echo osc_item_title();}?></a></h3>
                <p><strong><?php if (osc_item_city() != '') {echo osc_item_city();}if (osc_item_region() != '') {echo ' (' osc_item_region() . ')';}echo ' - ' osc_format_date(osc_item_pub_date()); echo ' - Total Views: '.ItemStats::newInstance()->getViews(osc_item_id()); ?> </strong> - <strong>expired : <?php echo time_diff1(osc_item_pub_date());?></strong></p>
                <p><?php echo osc_highlight(strip_tags(osc_item_description()));?></p>
                <p><a title="" href="<?php echo osc_item_url() ; ?>" class="btn pull-right">See More... <strong>&raquo;</strong></a></p>
                </div>
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="photo">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="125px" height="125px" title="" alt="" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" width="125px" height="125px" title="" alt="" />
                    <?php ?>
                 </div>
                 <?php ?>

             </div>
<?php ?>

<?php $ad_counter++;
        if (
$ad_counter == $adSense_middle_pos) {
            
//AdSense middle ?>

        <div class="item-list well">

// [Specific AdSense code here]

</div>
            <?php }

        <?
php ?>

As you can see the opening table-specific tags <tr><td colspan="2"> are replaced with <div class="item-list well">

and the closing table-specific tags </td></tr> are replaced with </div>

Regards
Title: Re: [TIP] Ads Between Listings
Post by: creat15 on July 11, 2014, 06:44:24 pm
Hi,

The element where each ad is wrapped on may vary from theme to theme, the key to adapt this code to your theme is here:

Quote
<?php $ad_counter++;
        if ($ad_counter == $adSense_middle_pos) {
            //AdSense middle ?>
        <tr><td colspan="2">

// [Specific AdSense code here]

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

Themes Modern, Minimalist, Bender and Infinity (already mentioned in this thread) and others use an HTML table, yours seems to use a div, so replace this block:

Code: [Select]
<?php while(osc_has_items()) { ?>
<?php if(!osc_item_is_premium()) { ?>
             <div class="item-list well">
               <div class="text">
                <p class="price">$ <?php if (osc_price_enabled_at_items()) {echo osc_item_formated_price();?></p>
                <h3><a href="<?php echo osc_item_url();?>"><?php echo osc_item_title();}?></a></h3>
                <p><strong><?php if (osc_item_city() != '') {echo osc_item_city();}if (osc_item_region() != '') {echo ' (' osc_item_region() . ')';}echo ' - ' osc_format_date(osc_item_pub_date()); echo ' - Total Views: '.ItemStats::newInstance()->getViews(osc_item_id()); ?> </strong> - <strong>expired : <?php echo time_diff1(osc_item_pub_date());?></strong></p>
                <p><?php echo osc_highlight(strip_tags(osc_item_description()));?></p>
                <p><a title="" href="<?php echo osc_item_url() ; ?>" class="btn pull-right">See More... <strong>&raquo;</strong></a></p>
                </div>
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="photo">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="125px" height="125px" title="" alt="" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" width="125px" height="125px" title="" alt="" />
                    <?php ?>
                 </div>
                 <?php ?>

             </div>
<?php ?>
        <?php ?>

with:

Code: [Select]
<?php 
    $adSense_middle_pos 
ceil(osc_count_items()/2);
    
$ad_counter 0;
    while(
osc_has_items()) { ?>

<?php if(!osc_item_is_premium()) { ?>
             <div class="item-list well">
               <div class="text">
                <p class="price">$ <?php if (osc_price_enabled_at_items()) {echo osc_item_formated_price();?></p>
                <h3><a href="<?php echo osc_item_url();?>"><?php echo osc_item_title();}?></a></h3>
                <p><strong><?php if (osc_item_city() != '') {echo osc_item_city();}if (osc_item_region() != '') {echo ' (' osc_item_region() . ')';}echo ' - ' osc_format_date(osc_item_pub_date()); echo ' - Total Views: '.ItemStats::newInstance()->getViews(osc_item_id()); ?> </strong> - <strong>expired : <?php echo time_diff1(osc_item_pub_date());?></strong></p>
                <p><?php echo osc_highlight(strip_tags(osc_item_description()));?></p>
                <p><a title="" href="<?php echo osc_item_url() ; ?>" class="btn pull-right">See More... <strong>&raquo;</strong></a></p>
                </div>
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="photo">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="125px" height="125px" title="" alt="" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" width="125px" height="125px" title="" alt="" />
                    <?php ?>
                 </div>
                 <?php ?>

             </div>
<?php ?>

<?php $ad_counter++;
        if (
$ad_counter == $adSense_middle_pos) {
            
//AdSense middle ?>

        <div class="item-list well">

// [Specific AdSense code here]

</div>
            <?php }

        <?
php ?>

As you can see the opening table-specific tags <tr><td colspan="2"> are replaced with <div class="item-list well">

and the closing table-specific tags </td></tr> are replaced with </div>

Regards

Hi :)

thanks for help its work for me :D
Title: Re: [TIP] Ads Between Listings
Post by: nootkan on July 29, 2014, 08:44:52 pm
Will this work for any banner ad setup or is it just for adsense banners?
Title: Re: [TIP] Ads Between Listings
Post by: cartagena68 on July 29, 2014, 08:51:43 pm
you can use it with different banners
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 29, 2014, 09:58:35 pm
In fact, you can put there whatever you want. Hey, why not a premium ad? ???

Regards
Title: Re: [TIP] Ads Between Listings
Post by: fog 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
Title: Re: [TIP] Ads Between Listings
Post by: teseo 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
Title: Re: [TIP] Ads Between Listings
Post by: fog on July 30, 2014, 03:16:06 am
Wow, this is amazing. Many thanks for all the light and dispensed code.  :)

Regards
Title: Re: [TIP] Ads Between Listings
Post by: Heartcore 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!
Title: Re: [TIP] Ads Between Listings
Post by: teseo 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
Title: Re: [TIP] Ads Between Listings
Post by: Heartcore on August 08, 2014, 08:55:27 am
ok then...

Thanks...
Title: Re: [TIP] Ads Between Listings
Post by: Omarcito 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.
Title: Re: [TIP] Ads Between Listings
Post by: teseo 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
Title: Re: [TIP] Ads Between Listings
Post by: user88 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>
Title: Re: [TIP] Ads Between Listings
Post by: keerthi on October 15, 2014, 11:50:22 am
whats your site.
Title: Re: [TIP] Ads Between Listings
Post by: user88 on October 15, 2014, 01:25:57 pm
www.cbay.it (http://www.cbay.it)
Title: Re: [TIP] Ads Between Listings
Post by: user88 on October 15, 2014, 04:16:07 pm
so?
Title: Re: [TIP] Ads Between Listings
Post by: keerthi on October 15, 2014, 10:25:31 pm
I am currently testing it with your theme. BTW It would be much wiser if you removed your ad code. You do know that anyone could get you banned right?
Title: Re: [TIP] Ads Between Listings
Post by: user88 on October 16, 2014, 02:59:55 am
ok. do you this is compatible?
Title: Re: [TIP] Ads Between Listings
Post by: user88 on October 16, 2014, 10:17:47 pm
no one want help me????
Title: Re: [TIP] Ads Between Listings
Post by: krak on October 18, 2014, 10:30:09 am
nice website looks good.
Title: Re: [TIP] Ads Between Listings
Post by: AdMeGreek on November 26, 2014, 12:32:53 am
any modification code for TuffClassified theme???
Title: Re: [TIP] Ads Between Listings
Post by: hashker on January 11, 2015, 05:53:36 pm
 i tried as you said but it is not working at my site. can u pls give me a help?
im using Flatter theme. my site kandyauto.lk

my loop.php

<?php
$loopClass = '';
$type = 'items';
if(View::newInstance()->_exists('listType')){
    $type = View::newInstance()->_get('listType');
}
if(View::newInstance()->_exists('listClass')){
    $loopClass = View::newInstance()->_get('listClass');
}
?>
<div class="row <?php if ($loopClass != '') { ?><?php echo $loopClass; ?><?php } else { ?>listing-list<?php } ?>">
    <?php
        $i = 0;

        if($type == 'latestItems'){
            while ( osc_has_latest_items() ) {
                $class = '';
                if($i%3 == 0){
                    $class = ' first';
                }
                flatter_draw_item($class);
                $i++;
            }
        } elseif($type == 'premiums'){
            while ( osc_has_premiums() ) {
                $class = '';
                if($i%3 == 0){
                    $class = ' first';
                }
                flatter_draw_item($class,false,true);
                $i++;
                if($i == 3){
                    break;
                }
            }
        } else {
            while(osc_has_items()) {
                $i++;
                $class = false;
                if($i%4 == 0){
                    $class = ' last';
                }
                $admin = false;
                if(View::newInstance()->_exists("listAdmin")){
                    $admin = true;
                }

                flatter_draw_item($class,$admin);
          }
        }
    ?>
</div>
Title: Re: [TIP] Ads Between Listings
Post by: teseo on January 11, 2015, 07:11:07 pm
Hi,

I don't have that theme, but looking at the structure of your search pages, I think this would be it:

search_list.php

Replace:

Code: [Select]
        } else {
            while(osc_has_items()) {
                $i++;
                $class = false;
                if($i%4 == 0){
                    $class = ' last';
                }
                $admin = false;
                if(View::newInstance()->_exists("listAdmin")){
                    $admin = true;
                }

                flatter_draw_item($class,$admin);
          }
        }
    ?>
</div>

with:

Code: [Select]
        } else {
            $adSense_middle_pos = ceil(osc_count_items()/2);
            $ad_counter = 0;

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

                flatter_draw_item($class,$admin);

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

                        // [Specific AdSense code here]

                    </div>
                    <?php }
          }
        }
    
?>

</div>

Regards
Title: Re: [TIP] Ads Between Listings
Post by: Akhim on April 20, 2015, 12:00:46 am
I have really tried to work around on how to do this on twitter theme but i can't hack it. Has anyone managed to? Please assist. Twitter theme has search_php, search_list.php, and search_gallery.php. I guess it should go to search_list.php but all the codes to replace as highlighted above by Teseo are missing.  Heeelp!
Title: Re: [TIP] Ads Between Listings
Post by: teseo on April 22, 2015, 11:53:29 pm
Hi,

Yes, each theme can have a different HTML structure. This should work for Twitter:

search-list.php:

1.- Look for this line:

Code: [Select]
<?php while ( osc_has_items() ) { ?>
and replace it with:

Code: [Select]
<?php $adSense_middle_pos ceil(osc_count_items()/2);
    
$ad_counter 0;
    while ( 
osc_has_items() ) { ?>


2.- Replace:

Code: [Select]
    <?php ?>
<?php ?>
<div class="pagination">

with:

Code: [Select]
    <?php $ad_counter++;
        if (
$ad_counter == $adSense_middle_pos) {
            
//AdSense middle ?>

        <div class="line span11 columns">
            [Specific AdSense code here]
        </div>
        <?php }
    } 
?>

<?php ?>
<div class="pagination">

Replace "[Specific AdSense code here]" with your actual AdSense code.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: Akhim on April 23, 2015, 08:49:14 am
Thank you Teseo!

It worked like charm. Happy happy happy  :)
Title: Re: [TIP] Ads Between Listings
Post by: gnoe on May 01, 2015, 10:54:49 pm
I tried the code below for Flatter theme but no success.
http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg113980/#msg113980 (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg113980/#msg113980)

Is someone with Flatter using/having the correct code?
Title: Re: [TIP] Ads Between Listings
Post by: gnoe on May 02, 2015, 09:11:33 am
After several tests the following code works for Flatter theme without any issues.
Parameter ShowAs is now sShowAs, DIV has a class with hidden-xs for small devices.
New variable $sShowAsParam and different if loop for gallery check.


Find in loop.php
Code: [Select]
        } else {
            while(osc_has_items()) {
                $i++;
                $class = false;
                if($i%4 == 0){
                    $class = ' last';
                }
                $admin = false;
                if(View::newInstance()->_exists("listAdmin")){
                    $admin = true;
                }

                flatter_draw_item($class,$admin);
          }
        }
    ?>
</div>


Replace it with this
Code: [Select]
        } else {
            $adSense_middle_pos = ceil(osc_count_items()/2);
    $sShowAsParam = Params::getParam('sShowAs');
            $ad_counter = 0;

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

                flatter_draw_item($class,$admin);

                $ad_counter++;
if ($sShowAsParam !='gallery' ) {
if ($ad_counter == 3 || $ad_counter == 6) { // 2 banners in 3rd and 6th positions
                     ?>
<div class="listing-card col-md-4 col-sm-6 hidden-xs">
...PUT ADSENSE CODE HERE...
                    </div>
                    <?php }
}
  }
}
    
?>

</div>

Thanks teseo.
Enjoy..
Title: Re: [TIP] Ads Between Listings
Post by: teseo on May 07, 2015, 01:13:37 pm
Thanks gnoe :)

I've added an index to this post (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99117/#msg99117) to help navigating the thread.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: wpark6765 on July 08, 2015, 09:45:26 pm
Hello, I would like to do this but I am kinda confused. Please help me out! And I am currently using Royal Theme.
THanks!!

#teseoineedhelp

Code: [Select]

    osc_get_premiums(10000);
    if(osc_count_premiums() > 4) {
?>
<table border="0" cellspacing="0">
     <tbody>
        <?php $class "even"?>
        <?php while(osc_has_premiums()) { ?>
            <div class="col-md-12 premium_<?php echo $class?> thumbnail">
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="col-md-3">
                     <?php if(osc_count_premium_resources()) { ?>
                        <a href="<?php echo osc_premium_url(); ?>"><img src="<?php echo osc_resource_thumbnail_url(); ?>" title="<?php echo osc_item_title(); ?>" alt="<?php echo osc_item_title(); ?>" /></a>
                    <?php } else { ?>
                        <a href="<?php echo osc_premium_url(); ?>"><img src="<?php echo osc_current_web_theme_url('images/no_photo.gif'); ?>" title="" alt="" /></a>
                    <?php ?>
                 </div>
                 <?php ?><span title="<?php _e('Premium listings''royal') ; ?>" class="cat-label cat-label-label2"><i class="fa fa-star"></i></span>
                 <div class="col-md-9 text kat1">
                     <h3>
                         <span><a href="<?php echo osc_premium_url(); ?>"><?php echo osc_highlightstrip_tagsosc_premium_title() ) ); ?></a></span>
                     </h3>
                     <small>
                         <strong><?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled(osc_premium_category_id()) ) { echo osc_premium_formated_price(); ?> </strong> </small>
<p><?php echo osc_highlightstrip_tagsosc_premium_description() ) ); ?></p>  <?php ?>
                 </div>
             </div>
            <?php $class = ($class == 'even') ? 'odd' 'even'?>
        <?php ?>
    </tbody>
</table>
<?php ?>
<table border="0" cellspacing="0">
    <tbody>
        <?php $class "even"$i 0?>
        <?php while(osc_has_items()) { $i++; ?>
            <div class="col-md-12 <?php echo $class?> thumbnail">
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="col-md-3">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url(); ?>"><img src="<?php echo osc_resource_thumbnail_url(); ?>"  title="<?php echo osc_item_title(); ?>" alt="<?php echo osc_item_title(); ?>" /></a>
                    <?php } else { ?>
                         <a href="<?php echo osc_item_url(); ?>"><img src="<?php echo osc_current_web_theme_url('images/no_photo.gif'); ?>" title="" alt="" /></a>
                    <?php ?>
                 </div>
                 <?php ?>
                 <div class="col-md-9 text kat1">
                     <h3>
                         <a href="<?php echo osc_item_url(); ?>"><?php echo osc_highlightstrip_tagsosc_item_title() ) ); ?></a>
                     </h3>
                     <small>
                         <strong><?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled() ) { echo osc_item_formated_price(); ?></strong></small>
                     <p><?php echo osc_highlightstrip_tagsosc_item_description() ) ); ?></p>  <?php ?>
                 </div>
             </div>
            <?php $class = ($class == 'even') ? 'odd' 'even'?>
             <?php if( $i == ) { ?>
    </tbody>
</table>
            <?php osc_run_hook('search_ads_listing_medium1'); ?>
<table border="0" cellspacing="0">
    <tbody>
            <?php ?>
        <?php ?>
    </tbody>
</table>
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 10, 2015, 12:51:09 am
Hi,

I don't know that theme but seems that could be done this way:

1.- Replace:

Code: [Select]
<?php while(osc_has_items()) { $i++; ?>

with:

Code: [Select]
<?php $adSense_middle_pos ceil(osc_count_items()/2);
while(
osc_has_items()) { $i++; ?>


2.- Replace:

Code: [Select]
<?php $class = ($class == 'even') ? 'odd' 'even'?>

with:

Code: [Select]
<?php if ($i+== $adSense_middle_pos) {
         
//AdSense middle ?>

        <div class="col-md-12 <?php echo $class = ($class == 'even') ? 'odd' 'even'?> thumbnail">

         // [Specific AdSense code here]

         </div>
<?php }
$class = ($class == 'even') ? 'odd' 'even'?>


Try and let me know if it works for you.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: wpark6765 on July 10, 2015, 08:41:46 am
WORKED LIKE A CHARM!! THanks!!!!

Hi,

I don't know that theme but seems that could be done this way:

1.- Replace:

Code: [Select]
<?php while(osc_has_items()) { $i++; ?>

with:

Code: [Select]
<?php $adSense_middle_pos ceil(osc_count_items()/2);
while(
osc_has_items()) { $i++; ?>


2.- Replace:

Code: [Select]
<?php $class = ($class == 'even') ? 'odd' 'even'?>

with:

Code: [Select]
<?php if ($i+== $adSense_middle_pos) {
         
//AdSense middle ?>

        <div class="col-md-12 <?php echo $class = ($class == 'even') ? 'odd' 'even'?> thumbnail">

         // [Specific AdSense code here]

         </div>
<?php }
$class = ($class == 'even') ? 'odd' 'even'?>


Try and let me know if it works for you.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 10, 2015, 12:42:24 pm
You're welcome. :) Could you tell me to which file of Royal theme belongs the code you pasted here?

Regards
Title: Re: [TIP] Ads Between Listings
Post by: wpark6765 on July 11, 2015, 04:59:10 am
yes, it's from search_list.php

You're welcome. :) Could you tell me to which file of Royal theme belongs the code you pasted here?

Regards
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 11, 2015, 02:39:35 pm
Thanks. Added now to the index post:

http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99117/#msg99117 (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99117/#msg99117)

Regards
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 13, 2015, 08:22:40 pm
Hi,

What theme is that and where can I see a demo? ???

Regards
Title: Re: [TIP] Ads Between Listings
Post by: teseo on July 17, 2015, 04:39:52 pm
Important note: I've programmed this in a way that will only work for List View, to insert a single "fake regular ad" on Gallery View would scramble the symmetry of the grid layout. :( You'd need to insert 4 AdSenses to keep things pretty...  ???

Given that your One theme seems to work only in Gallery View, this procedure is not appliable as it is.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: fog on September 25, 2015, 04:11:51 pm
Today I did a alternative for user profile without pagination. I tried some codes on the forum for pagination, but without success for while, maybe I did something wrong, or my repurpose theme don't liked of these codes. If you know some code functional for pagination on user public profile, post the link, I'll appreciate that.

With this generic code with variables and conditions I can choose the correct position of my banner or other situation.

Some parameters if on case not correspond with total items of user comparing with position number of the banner, it will reset to second position on the listings.

All code is commented for follow the process, if you decide use it for same reasons, you can delete all comments if you want.

I tested the code only without pagination on list mode (I don't use gallery mode on my theme), maybe it works with pagination, and with gallery mode.
If you find some problem post here.

Regards

Code: [Select]
<?php
$adSense_middle_pos 
ceil(osc_count_items());
$selected_position 2/* Change to select position independent of number items per page on public profile. */
if($selected_position >= 2){
$fix_number_position $selected_position 1/* Correct position on listings. */
$regenerate $fix_number_position osc_count_items(); /* Will regenerate the number, subtracting the number position with total of items. */
if($fix_number_position osc_count_items()){/* Verify the selected position number if is bigger than total items. */
$ad_counter osc_count_items() - $regenerate/* Is a bigger number, so need subtract with regenerate value. */
} elseif (
$fix_number_position osc_count_items()){/* Verify the reduced number if is less than total items. */
$ad_counter osc_count_items() - $fix_number_position; /* Is a less number, so need subtract the value of position number fixed, with total number of items. */
} elseif (
$fix_number_position == osc_count_items()){/* Verify the reduced number if is equal to total items. */
$ad_counter osc_count_items() - 1/* Will stay in second position by default */
}
} else {
$reset_second_position 1;
$ad_counter osc_count_items() - $reset_second_position/* Will stay in second position by default if selected position value is less than 2 */
}
?>

Title: Re: [TIP] Ads Between Listings
Post by: servicesmary on February 22, 2016, 02:39:15 am
Hello,

I've tried this with osclasswizards without success.
With text "Adsence" for test, i see it one time but don't repeat and change a lot display of grid.
It seems workd in list.

Someone have find the solution for grid ?
Title: Re: [TIP] Ads Between Listings
Post by: teseo on February 22, 2016, 05:27:01 pm
Hi,

Important note: I've programmed this in a way that will only work for List View, to insert a single "fake regular ad" on Gallery View would scramble the symmetry of the grid layout. :( You'd need to insert 4 AdSenses to keep things pretty...  ???

I'm afraid the Gallery/Grid view has a much more complex structure (and maybe not the same depending on theme ???).

Regards
Title: Re: [TIP] Ads Between Listings
Post by: servicesmary on February 23, 2016, 02:45:39 am
Hi Teseo,

Thanks for your response.

I think i am near the solution. Time miss me now. If i find it, I'll write it here.
Title: Re: [TIP] Ads Between Listings
Post by: fosg2000 on June 20, 2016, 06:55:46 pm
how to on Boxer theme??
Title: Re: [TIP] Ads Between Listings
Post by: bredis on November 07, 2016, 12:20:26 pm
Hi,

I have one question. I use modern theme and have 4 categories. Would be possible to add different banner to each category?

For example if I have category hotels I would like to show some banner typical for the category.

In this way I can show banner in all categories but in some of them it isn't relevant.

Thanks.
Title: Re: [TIP] Ads Between Listings
Post by: p206ab on August 20, 2017, 05:46:29 pm
Any updates on gallery view option?  :D
Title: Re: [TIP] Ads Between Listings
Post by: abdul ghany syed on August 22, 2017, 09:30:05 am
How to setup ads between listing in veronika,

The above methods not worked for me in veronika theme

is there anyone who know well about this?
Title: Re: [TIP] Ads Between Listings
Post by: teseo on August 22, 2017, 03:33:48 pm
Hi,

Any updates on gallery view option?  :D

Sorry, this still applies:

https://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg136758/#msg136758

The above methods not worked for me in veronika theme

As said, this is only for List view (I can see Veronika uses Gallery view as default), and even for List view you need to understand the logic of the code to adapt it to your theme.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: abdul ghany syed on August 26, 2017, 12:19:45 am
Hi,

Any updates on gallery view option?  :D

Sorry, this still applies:

https://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg136758/#msg136758

The above methods not worked for me in veronika theme

As said, this is only for List view (I can see Veronika uses Gallery view as default), and even for List view you need to understand the logic of the code to adapt it to your theme.

Regards

Thanks for your confirmation...
Title: Re: [TIP] Ads Between Listings
Post by: jacques1966 on September 16, 2017, 07:51:04 am
www.cbay.it (http://www.cbay.it)

Dude !!!
I like your site - the sliders all work very professional !

What theme are you using?

Any chance of sending me the code?

Title: Re: [TIP] Ads Between Listings
Post by: Aficionado on September 16, 2017, 01:26:36 pm
www.cbay.it (http://www.cbay.it)

Dude !!!
I like your site - the sliders all work very professional !

What theme are you using?

Any chance of sending me the code?

Title: Re: [TIP] Ads Between Listings
Post by: jacques1966 on September 17, 2017, 02:49:58 pm
Thanks Aficionado

I didn't think of doing a "inspect" to look for the theme name.

Is this theme still available? [I typed "Celio" in the theme search at osclass markets - but nada]

Title: Re: [TIP] Ads Between Listings
Post by: cartagena68 on September 17, 2017, 04:58:17 pm
I think is a modified version of infinity theme, but i think is no more available on osclass market.
Title: Re: [TIP] Ads Between Listings
Post by: jacques1966 on September 18, 2017, 05:31:18 am
I think is a modified version of infinity theme, but i think is no more available on osclass market.

Sadly so it seems..... :-[
Title: Re: [TIP] Ads Between Listings
Post by: ala on September 22, 2017, 02:51:16 pm
i want to add absent code in search page for veronika theme , how can i do? please help me,
this is loop-single.php
Title: Re: [TIP] Ads Between Listings
Post by: goodisme on September 26, 2017, 12:33:45 pm
Hi Guys , i use sahara theme. i tried using the provided codes but it is not working. see the coding for my search-list.php

Code: [Select]
<div class="catalogi"><h4><?php _e("Special Ads"'sahara'); ?></h4></div>
<div class="product-pages">
<?php while ( osc_has_premiums() ) { ?>
                    <div class="list-product premi">
                         <div class="product-kiri">
<div class="label-premium hidden-vera-up"><?php _e("Special"'sahara'); ?><b></b></div>
                                <div class="ribbon ribbon-green">
                                <div class="banner">
                                    <div class="text"><?php _e("Special"'sahara'); ?></div>
                                </div></div>
                               <?php if( osc_count_premium_resources() ) { ?>
                                      <a class="arve" href="<?php echo osc_premium_url() ; ?>"><img class="gambars" src="<?php echo osc_resource_thumbnail_url() ; ?>" alt="<?php echo osc_esc_html(osc_premium_title()) ; ?>" title="<?php echo osc_esc_html(osc_premium_title()) ; ?>"></a>
                                <?php } else { ?>
                                      <a href="<?php echo osc_premium_url() ; ?>"><img class="gambars" src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" alt="<?php echo osc_esc_html(osc_premium_title()) ; ?>" title="<?php echo osc_esc_html(osc_premium_title()) ; ?>"/></a>
                                <?php ?>
                          </div>
                          <div class="product-tengah">
                             
                              <h3 class="judul"><a href="<?php echo osc_premium_url() ; ?>"><?php echo osc_premium_title(); ?> </a></h3>
                              <?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled(osc_premium_category_id()) ) { ?>
                             <div class="pricemini pricolor hidden-xs-up" style="color:#2F4F4F">
              <?php echo osc_format_price(osc_premium_price(), osc_premium_currency_symbol()); ?>
                     </div>   
                            <?php ?>
                              <div class="kontens"><p><?php echo osc_highlightstrip_tagsosc_premium_description() ) ); ?></p></div>
                              <div class="loc"><?php if(osc_premium_city()!='' ) { ?><span class="lokas"><strong><i class="fa fa-map-marker" style="color:red"></i></strong>
                              <?php echo osc_premium_city(); ?></span>
                              <?php ?>
                              <?php if(osc_premium_region()!='' ) { ?>&middot;
                              <span class="lokas2"><?php echo osc_premium_region(); ?></span>
                              <?php ?> <span class="catt"><strong><i class="fa fa-book" style="color:brown"></i></strong> <?php echo osc_premium_category($locale ""); ?></span> <span class="datt"><strong><i class="fa fa-calendar" style="color:orange"></i></strong> <?php echo osc_format_date(osc_premium_pub_date()); ?></span></div>
<?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled(osc_premium_category_id()) ) { ?>
<div class="tags price-wrap  hidden-xs-down">
<span class="tag-head"><p class="post-price"><?php echo osc_format_price(osc_premium_price(), osc_premium_currency_symbol()); ?></p></span>
</div>
 <?php ?>
                         </div>
                    </div>
              <?php ?>

<?php ?></div>
<div class="catalog"><h4 style="margin-top:10px;color: #2F4F4F !important;font-weight: bold !important;text-align: center;font-size: 1em;border-bottom: 1px solid #ddd;"><?php _e("Latest Ads"'sahara'); ?></h4></div>
<div class="product-pages">
<?php  $adSense_middle_pos ceil(osc_count_items()/2);
while ( 
osc_has_items() ) { ?>

                      <div class="<?php osc_run_hook("highlight_class"); ?> list-product news reguler">
                      <div class="product-kiri">
<?php if( osc_item_is_premium() ) { ?>
<div class="label-premium  hidden-vera-up"><?php _e("Special"'sahara'); ?><b></b></div>
<?php ?>
                           <?php if( osc_item_is_premium() ) { ?> <div class="ribbon ribbon-green">
                                <div class="banner">
                                    <div class="text"><?php echo osc_esc_html(__('Special','sahara')); ?></div>
                                </div></div><?php ?>
                           <?php if( osc_images_enabled_at_items() ) { ?>
                           <?php if(osc_count_item_resources()) { ?>
                               <a class="arve" href="<?php echo osc_item_url(); ?>"><img class="gambars" src="<?php echo osc_resource_thumbnail_url(); ?>" alt="<?php echo osc_esc_html(osc_item_title()) ; ?>" title="<?php echo osc_esc_html(osc_item_title()) ; ?>"></a>
                          <?php } else { ?>
                                <a href="<?php echo osc_item_url(); ?>"><img class="gambars" src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" alt="<?php echo osc_esc_html(osc_item_title()) ; ?>" title="<?php echo osc_esc_html(osc_item_title()) ; ?>"/></a>
                          <?php ?>
                          <?php ?>
                     </div>
                     <div class="product-tengah">
                            <h3 class="judul"><a alt="<?php echo osc_esc_html(osc_item_title()) ; ?>" title="<?php echo osc_esc_html(osc_item_title()) ; ?>" href="<?php echo osc_item_url(); ?>"><?php echo osc_item_title(); ?></a></h3>
                            <?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled() ) { ?>
                            <div class="pricemini pricolor hidden-xs-up" style="color:#2F4F4F;">
              <?php echo osc_format_price(osc_item_price()); ?>
                     </div>   
                     <?php ?>
                            <div class="kontens"><p><?php echo osc_highlightstrip_tagsosc_item_description() ) ); ?></p></div>
                            <div class="loc"><?php if(osc_item_city()!='' ) { ?><span class="lokas"><strong><i class="fa fa-map-marker" style="color:red"></i></strong>
                            <?php echo osc_item_city(); ?></span>
                            <?php ?>
                            <?php if(osc_item_region()!='' ) { ?>&middot;
                            <span class="lokas2"><?php echo osc_item_region(); ?></span>
                            <?php ?> <span class="catt"><strong><i class="fa fa-book" style="color:brown"></i></strong> <?php echo osc_item_category($locale ""); ?></span> <span class="datt"><strong><i class="fa fa-calendar" style="color:#FFFC42"></i></strong> <?php echo osc_format_date(osc_item_pub_date()); ?></span></div>
<?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled() ) { ?>
 <div class="tags price-wrap  hidden-xs-down">
<span class="tag-head"><p class="post-price"><?php echo osc_format_price(osc_item_price()); ?></p></span>
</div>                           
<?php ?>
                      </div>
                      </div>
           
            <?php if ($i+== $adSense_middle_pos) {
         
//AdSense middle ?>

        <div class="list-product news reguler">

         // [Specific AdSense code here]

         </div>
<?php }
Title: Re: [TIP] Ads Between Listings
Post by: Aficionado on September 28, 2017, 07:55:43 pm
Has anyone applied this to OsclassWizards theme ?
Title: Re: [TIP] Ads Between Listings
Post by: p206ab on October 09, 2017, 08:17:24 pm
Did something change in 3.7.4. or am I doing something wrong?
I've tried editing loop in infinity and bender on two separate installations, one fresh test just for this purpose, but I'm not seeing anything, regardless what I insert in adsense code part..text, image...?
Title: Re: [TIP] Ads Between Listings
Post by: ayman83 on October 17, 2017, 06:37:02 pm
I use AiClassy theme, I think that theme is bender dependant.
However, I have no result when I insert the specific code for bender.
I use the latest version of OSClass 3.7.4.
Does it have changes that prevent that code from working?
Title: Re: [TIP] Ads Between Listings
Post by: teseo on October 18, 2017, 02:31:59 pm
Hi,

Has anyone applied this to OsclassWizards theme ?

For Osclass Wizards you need to modify oc-content/themes/osclasswizards/loop-search-list.php

1.-

Code: [Select]
        else {
            while (osc_has_items()) {

Replace with:

Code: [Select]
        else {
            $adSense_middle_pos = ceil(osc_count_items() / 2);
            $ad_counter = 0;

            while (osc_has_items()) {

2.- And, at the end of the script:

Code: [Select]
  <?php
        
}
  }
?>

</ul>

Replace with:

Code: [Select]
                <?php $ad_counter++;
                if (
$ad_counter == $adSense_middle_pos) {
                    
//AdSense middle 
                    
?>

                    <li class="listing-card">
                        <div class="list_space">
                            // [Specific AdSense code here]
                        </div>
                    </li>
                <?php
                
}
            }
        } 
?>

</ul>

Regards
Title: Re: [TIP] Ads Between Listings
Post by: teseo on October 18, 2017, 02:36:59 pm
Hi,

Did something change in 3.7.4. or am I doing something wrong?
I've tried editing loop in infinity and bender on two separate installations, one fresh test just for this purpose, but I'm not seeing anything, regardless what I insert in adsense code part..text, image...?

Things have changed in the last 3 years, see here (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99119/#msg99119) for updated Bender code, and here (http://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg99740/#msg99740) for Infinity.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: ayman83 on October 18, 2017, 07:55:49 pm
I am glad for your help teseo, appreciate your efforts and thank you for everything.

unfortunately, the code you updated for Bender theme makes this error in the attached image, can you help me again to fix it?

Title: Re: [TIP] Ads Between Listings
Post by: teseo on October 18, 2017, 08:58:59 pm
I can't help you, I don't have that theme.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: ayman83 on October 18, 2017, 09:32:08 pm
Sorry teaeo, it was my mistake by inserting the code in wrong way.
now the error was fixed, and the ad appears between listings.  :D
 
Please, may I have your advice on these topics:

How can I customize each category?
https://forums.osclass.org/general-help/how-can-i-customize-each-category/

How can I put a placeholder in any field?
https://forums.osclass.org/general-help/how-can-i-put-a-placeholder-in-any-field/?topicseen

 How to make premium listings in search page more than 5?
https://forums.osclass.org/general-help/how-to-make-premium-listings-in-search-page-more-than-5/
Regards,
Title: Re: [TIP] Ads Between Listings
Post by: p206ab on November 26, 2017, 09:47:47 pm
I finally managed to make it work in Infinity, but how do I apply this also for home page (latest items)?
Thanks.  ;)
Title: Re: [TIP] Ads Between Listings
Post by: teseo on November 27, 2017, 01:11:22 pm
Sorry, I don't have access to any installation using Infinity theme anymore.

Regards
Title: Re: [TIP] Ads Between Listings
Post by: p206ab on November 28, 2017, 12:13:33 am
Sorry, I don't have access to any installation using Infinity theme anymore.

Regards

Well, since it's the same as bender, only renamed, do you possibly know how to make it there? I'll remake it for Infinity by myself then (and post it here for future reference).
Thanks.
Title: Re: [TIP] Ads Between Listings
Post by: teseo on November 28, 2017, 01:47:30 pm
OK.

For Latest Listings on Bender you need to modify oc-content/themes/bender/loop.php

This block:

Code: [Select]
        if($type == 'latestItems'){
            while ( osc_has_latest_items() ) {
                $class = '';
                if($i%3 == 0){
                    $class = 'first';
                }
                bender_draw_item($class);
                $i++;
            }
        } elseif($type == 'premiums'){

Replace with:

Code: [Select]
        if($type == 'latestItems'){
            $adSense_middle_pos = ceil(osc_count_latest_items()/2);
            $ad_counter = 0;
            while ( osc_has_latest_items() ) {
                $class = '';
                if ($i % 3 == 0) {
                    $class = 'first';
                }
                bender_draw_item($class);
                $i++;

                $ad_counter++;
                if ($ad_counter == $adSense_middle_pos && bender_show_as() == 'list') {
                    //AdSense middle
                    ?>
                    <li class="listing-card">

                        // [Specific AdSense code here]

                    </li>
                <?php }
            }
        } elseif(
$type == 'premiums'){

Regards
Title: Re: [TIP] Ads Between Listings
Post by: p206ab on November 28, 2017, 09:30:08 pm
Thanks teseo, works like a charm.  :)
For infinity, all that is required is change the two bender words into infinity, the rest is the same, so

infinity_draw_item($class);
infinity_show_as() == 'list'

Title: Re: [TIP] Ads Between Listings
Post by: mrtsoftware on February 05, 2018, 03:57:06 pm
How to do same in Osclass Wizards theme?
Title: Re: [TIP] Ads Between Listings
Post by: teseo on February 05, 2018, 04:03:39 pm
Hi,

For Osclass Wizards, see here:

https://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg157104/#msg157104

Regards
Title: Re: [TIP] Ads Between Listings
Post by: sewalaku on May 13, 2018, 09:31:42 am
<?php
    /*
     *       Rich Responsive Osclass Themes
     *       
     *       Copyright (C) 2016 OSCLASS.me
     *
     *       This is Rich Osclass Themes with Single License
     * 
     *       This program is a commercial software. Copying or distribution without a license is not allowed.
     *         
     *       If you need more licenses for this software. Please read more here <http://www.osclass.me/osclass-me-license/>.
     */

    osc_get_premiums();
    if(osc_count_premiums() > 0) {
?>
<div class="lg-12 md-12">
<div class="bmw">
        <?php while(osc_has_premiums()) { ?>
           <div class="kontena lg-12 md-12 premium topper">
                <?php if( osc_images_enabled_at_items() ) { ?>
                 <div class="lg-2 md-2 xs-4 oner">
                     <?php if(osc_count_premium_resources()) { ?>
                        <a href="<?php echo osc_premium_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" title="<?php echo osc_item_title(); ?>" alt="<?php echo osc_item_title(); ?>" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" title="" alt="" />
                    <?php } ?>
                 </div>
                 <?php } ?>
                 <div class="lg-10 md-10 xs-8 twor">
                     <div class="judula"><h3><a href="<?php echo osc_premium_url() ; ?>"><?php echo osc_premium_title() ; ?></a></h3></div>
<div class="locatte"><span class="hargas"><?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled(osc_premium_category_id()) ) { ?><?php echo osc_format_price(osc_premium_price(), osc_premium_currency_symbol()); ?><?php } ?></span><span class="cat-label cat-label-label2"><i class="fa fa-star"></i> <?php _e('Premium', 'rich') ; ?></span></div>
                      <div class="localer mini-none"> <p><?php echo osc_highlight( osc_premium_description() ,300) ; ?></p></div>
                     <div class="localer">
                        <span><i class="fa fa-calendar"></i>  <?php echo osc_format_date(osc_premium_pub_date()); ?>  <i class="fa fa-map-marker"></i>  <?php echo osc_premium_city(); ?> <span class="mini-none">(<?php echo osc_premium_region(); ?>)</span> </span>
                     </div>
                 </div></div>
        <?php } ?>
<?php } ?>
<?php while(osc_has_items()) { ?>
             <div class="kontena lg-12 md-12 standart topper">
                <?php if( osc_images_enabled_at_items() ) { ?>
                  <div class="lg-2 md-2 xs-4 oner">
                     <?php if(osc_count_item_resources()) { ?>
                        <a href="<?php echo osc_item_url() ; ?>"><img src="<?php echo osc_resource_thumbnail_url() ; ?>" title="<?php echo osc_item_title(); ?>" alt="<?php echo osc_item_title(); ?>" /></a>
                    <?php } else { ?>
                        <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" title="" alt="" />
                    <?php } ?>
                 </div>
                 <?php } ?>
                  <div class="lg-10 md-10 xs-8 twor">
                     <div class="judula"><h3>
                         <a href="<?php echo osc_item_url() ; ?>"><?php echo osc_item_title() ; ?></a></h3></div>
<div class="locatte"><span class="hargas"> <?php if( osc_price_enabled_at_items() && osc_item_category_price_enabled() ) { ?><?php echo osc_format_price(osc_item_price()); ?><?php } ?></span><?php if( osc_item_is_premium() ) { ?>
                 <span class="cat-label cat-label-label2"><i class="fa fa-star"></i> <?php _e('Premium', 'rich') ; ?></span>
                 <?php } ?></div>
                    <div class="localer"> <p class="mini-none"><?php echo osc_highlight( osc_item_description() ,300) ; ?></p></div>
                    <div class="localer"><span><i class="fa fa-calendar"></i>  <?php echo osc_format_date(osc_item_pub_date()); ?> </span><span>  <i class="fa fa-map-marker"></i>  <?php echo osc_item_city(); ?> <span class="mini-none"(<?php echo osc_item_region(); ?>)</span> </span>
                     </div>
                     
                 </div>
              </div>
        <?php } ?>
   

</div>
</div>





this is my seacrh_list.php.
 :-[ :-[ :-[ :-[ FRIEND PLASE HELP MEE  PLASE
i can'at view ads
Title: Re: [TIP] Ads Between Listings
Post by: Ibowills on August 14, 2018, 08:22:46 am
Hi,

New installation of osclass 3.8.0, default theme.  Only Country is appearing after I add. For region after I search and add, it says added but does not appear. While city no way to add at all. I want all region or cities to appear or drop down list. How to fix?
Title: Re: [TIP] Ads Between Listings
Post by: Aficionado on August 14, 2018, 12:22:10 pm
Hi,

New installation of osclass 3.8.0, default theme.  Only Country is appearing after I add. For region after I search and add, it says added but does not appear. While city no way to add at all. I want all region or cities to appear or drop down list. How to fix?

What that question has to do with the topic ? Please do not post to old topics or irrelevant ones. Open a new Topic in the Proper Forum.
Title: Re: [TIP] Ads Between Listings
Post by: bgd on January 04, 2019, 02:29:08 pm
Hello,

How I can display only 2 or 3 random ads beetwing listings? I can use only 3 google adsense ads because I use scrolling page.

Title: Re: [TIP] Ads Between Listings
Post by: bgd on January 11, 2019, 08:32:49 am
anyone  please :'(
Title: Re: [TIP] Ads Between Listings
Post by: Darwazo on April 12, 2019, 04:42:21 am
Hi Teseo and all helping hands .....

i am using Veronika theme....& still learning in bits and pieces
I got help from theme forum but still this one is yet to be resolved ...

Pls. help me ....i want to put adsense ad after every 3rd ad listing in search result.....

Currently I had pasted Adsense in Ads Management Tab of theme but getting only ONE Ad.


My current relevant code on search list is :


  <?php $c = 1; ?>
  <?php while(osc_has_items()) { ?>

    <?php veronika_draw_item($c, 'list'); ?>

    <?php if($c == 3) { ?>
      <?php echo veronika_banner('search_list'); ?>
    <?php } ?>

    <?php $c++; ?>
  <?php } ?>
</div>


Thanks




Suggested solution which didn't work for me......or how to use this ...

---------------------------------------------------------------------------------------------
<?php $count = 0; ?>
<?php while(osc_has_items()) { ?>
<?php $count++; ?>
<?php if( $count/4 == 1 || $count/4 == 2 || $count/4 == 3  || $count/4 == 4) { ?>
<?php echo show_banner( 1 ); ?>

<?php } ?>
----------------------------------------------------------------------------------------------
darwazo.com
Title: Re: [TIP] Ads Between Listings
Post by: casper on June 27, 2019, 03:49:20 pm
Hi Teseo and all helping hands .....

i am using Veronika theme....& still learning in bits and pieces
I got help from theme forum but still this one is yet to be resolved ...

Pls. help me ....i want to put adsense ad after every 3rd ad listing in search result.....

Currently I had pasted Adsense in Ads Management Tab of theme but getting only ONE Ad.


My current relevant code on search list is :


  <?php $c = 1; ?>
  <?php while(osc_has_items()) { ?>

    <?php veronika_draw_item($c, 'list'); ?>

    <?php if($c == 3) { ?>
      <?php echo veronika_banner('search_list'); ?>
    <?php } ?>

    <?php $c++; ?>
  <?php } ?>
</div>


Thanks




Suggested solution which didn't work for me......or how to use this ...

---------------------------------------------------------------------------------------------
<?php $count = 0; ?>
<?php while(osc_has_items()) { ?>
<?php $count++; ?>
<?php if( $count/4 == 1 || $count/4 == 2 || $count/4 == 3  || $count/4 == 4) { ?>
<?php echo show_banner( 1 ); ?>

<?php } ?>
----------------------------------------------------------------------------------------------
darwazo.com

Code: [Select]
  <?php $c 1?>
  <?php while(osc_has_items()) { ?>

    <?php veronika_draw_item($c'list'); ?>

    <?php if($c == 3) { ?>
      <?php echo veronika_banner('search_list'); ?>
    <?php ?>
    <?php if($c == 5) { ?>
      <?php echo veronika_banner('search_list'); ?>
    <?php ?>
    <?php $c++; ?>
  <?php ?>

Change the order number
<?php if($c == 3) { ?>

Title: Re: [TIP] Ads Between Listings
Post by: Darwazo on July 20, 2019, 06:11:00 am
Thanks alot !!
I had managed to resolve it ...