Advertisement:

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

keerthi

  • Hero Member
  • *****
  • Posts: 505
Re: [TIP] Ads Between Listings
« Reply #30 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?

user88

  • Jr. Member
  • **
  • Posts: 81
Re: [TIP] Ads Between Listings
« Reply #31 on: October 16, 2014, 02:59:55 am »
ok. do you this is compatible?

user88

  • Jr. Member
  • **
  • Posts: 81
Re: [TIP] Ads Between Listings
« Reply #32 on: October 16, 2014, 10:17:47 pm »
no one want help me????

krak

  • Newbie
  • *
  • Posts: 40
Re: [TIP] Ads Between Listings
« Reply #33 on: October 18, 2014, 10:30:09 am »
nice website looks good.

AdMeGreek

  • Full Member
  • ***
  • Posts: 101
Re: [TIP] Ads Between Listings
« Reply #34 on: November 26, 2014, 12:32:53 am »
any modification code for TuffClassified theme???

hashker

  • Newbie
  • *
  • Posts: 1
Re: [TIP] Ads Between Listings
« Reply #35 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>

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #36 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
« Last Edit: July 11, 2015, 02:37:34 pm by teseo »

Akhim

  • Newbie
  • *
  • Posts: 34
Re: [TIP] Ads Between Listings
« Reply #37 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!

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #38 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

Akhim

  • Newbie
  • *
  • Posts: 34
Re: [TIP] Ads Between Listings
« Reply #39 on: April 23, 2015, 08:49:14 am »
Thank you Teseo!

It worked like charm. Happy happy happy  :)

gnoe

  • Full Member
  • ***
  • Posts: 237
Re: [TIP] Ads Between Listings
« Reply #40 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

Is someone with Flatter using/having the correct code?

gnoe

  • Full Member
  • ***
  • Posts: 237
Re: [TIP] Ads Between Listings
« Reply #41 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..

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #42 on: May 07, 2015, 01:13:37 pm »
Thanks gnoe :)

I've added an index to this post to help navigating the thread.

Regards

wpark6765

  • Newbie
  • *
  • Posts: 13
Re: [TIP] Ads Between Listings
« Reply #43 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>
« Last Edit: July 09, 2015, 05:03:56 am by wpark6765 »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] Ads Between Listings
« Reply #44 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
« Last Edit: July 10, 2015, 12:59:52 am by teseo »