Advertisement:

Author Topic: (Solved) Premium Ads "Always on top" question  (Read 5148 times)

geoo212

  • Newbie
  • *
  • Posts: 33
(Solved) Premium Ads "Always on top" question
« on: January 07, 2015, 03:18:07 pm »
Hi,
I use bender theme and i want to ask how can i enable"Always on top" feature to show premium ads before normal ads. Now i see the premium ads on every page. I want to see premium ads just before the normal ads.

For example, if i have 8 premium ads and a limit of 10 ads on page, i want to see on a page the 8(premium ads) + 2 (normal ads) and on the next page to show only the normal ads because the premium ads have been listed already.

Thanks!
« Last Edit: January 09, 2015, 02:43:04 pm by geoo212 »

aide2001

  • Guest
Re: Premium Ads "Always on top" question
« Reply #1 on: January 08, 2015, 07:41:08 pm »
Hi there
you could try something like

<?php if (osc_search_page() == 0) {?>


<?php
            $i = 0;
            osc_get_premiums(6);
            if(osc_count_premiums() > 0) {
                echo '<h1><strong>Premium Listings</strong></h1>';
                echo '<ul class="listing-card-list '.$listClass.' premium-list" id="listing-card-list">';
                while ( osc_has_premiums() ) {
                    $class = '';
                    if($i%4 == 0){
                        $class = 'first';
                    }
                    bender_draw_item($class,false,true);
                    $i++;
                    if($i == 6){
                        break;
                    }
                }
                echo '</ul>';
            }
         ?>



<?php if(osc_count_items() > 0) {  ?>
<div class="clear"></div><br />
<h1><strong>Free Listings</strong></h1>
<ul class="listing-card-list <?php echo $listClass; ?>" id="listing-card-list">
<?php $i = 0; while(osc_has_items()) { $i++; ?>
<?php
$class = false;
 if($i%4 == 0){
$class = 'last';}
bender_draw_item($class); ?>
<?php } ?></ul><?php } ?>


<?php } else { ?>



<?php if(osc_count_items() > 0) {  ?>
<div class="clear"></div><br />
<h1><strong>Free Listings</strong></h1>
<ul class="listing-card-list <?php echo $listClass; ?>" id="listing-card-list">
<?php $i = 0; while(osc_has_items()) { $i++; ?>
<?php
$class = false;
 if($i%4 == 0){
$class = 'last';}
bender_draw_item($class); ?>
<?php } ?></ul><?php } ?>


<?php } ?>

In your search.php
this is an easy way, there maybe better ways and less configured options, but you havent said what  osclass your running.
« Last Edit: January 08, 2015, 07:43:53 pm by aide2001 »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Premium Ads "Always on top" question
« Reply #2 on: January 09, 2015, 12:43:28 am »
***CORRECTED***

Hi,

There is already a solution here:

http://forums.osclass.org/general-help/proper-ads-sorting-please-move-this-to-tips-and-tricks/msg94617/#msg94617

Even simpler:

1.- Add this at the very bottom of Bender functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_all_premiums_ontop($params) {
    if (!
$params['sOrder']) Search::newInstance()->order('b_premium desc, dt_pub_date''desc');
}

osc_add_hook('search_conditions''cust_all_premiums_ontop');
?>


2.- To disable the normal block of premiums on the top of every search page, just comment this line in bender/search.php:

Code: [Select]
// osc_get_premiums();
Regards
« Last Edit: January 09, 2015, 06:13:48 pm by teseo »

geoo212

  • Newbie
  • *
  • Posts: 33
Re: Premium Ads "Always on top" question
« Reply #3 on: January 09, 2015, 02:42:32 pm »
Thanks all. I used teseo solution. Thanks again man!

Regards

geoo212

  • Newbie
  • *
  • Posts: 33
Re: Premium Ads "Always on top" question
« Reply #4 on: January 09, 2015, 05:45:42 pm »
Hi,

There is already a solution here:

http://forums.osclass.org/general-help/proper-ads-sorting-please-move-this-to-tips-and-tricks/msg94617/#msg94617

Even simpler:

1.- Add this at the very bottom of Bender functions.php (take care not to leave blank lines after this):

Code: [Select]
<?php
function cust_all_premiums_ontop() {
        
Search::newInstance()->order('b_premium desc, dt_pub_date''desc');
}

osc_add_hook('search_conditions''cust_all_premiums_ontop');
?>


2.- To disable the normal block of premiums on the top of every search page, just comment this line in bender/search.php:

Code: [Select]
// osc_get_premiums();
Regards

I have a little problem: when i want to sort the listings by price.. biggest to lowest or opposite isn't working. what cand i do? Thanks again

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: (Solved) Premium Ads "Always on top" question
« Reply #5 on: January 09, 2015, 06:15:39 pm »
Right, now everything will return to default behaviour if any ordering is applied:

Code: [Select]
<?php
function cust_all_premiums_ontop($params) {
    if (!
$params['sOrder']) Search::newInstance()->order('b_premium desc, dt_pub_date''desc');
}

osc_add_hook('search_conditions''cust_all_premiums_ontop');
?>


Regards

geoo212

  • Newbie
  • *
  • Posts: 33
Re: (Solved) Premium Ads "Always on top" question
« Reply #6 on: January 10, 2015, 07:12:25 pm »
Ok. Thanks! :)

Maybe i'm asking to much, but is possible for the premium ads to remain on top after order? or to arrange themselves on top?

Thanks again, teseo!

aide2001

  • Guest
Re: (Solved) Premium Ads "Always on top" question
« Reply #7 on: January 10, 2015, 07:29:00 pm »
ignore my answer then @geoo212 , it works like you asked,
premium ads on top first page only, and doesnt change if you reorder it.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: (Solved) Premium Ads "Always on top" question
« Reply #8 on: January 10, 2015, 07:30:57 pm »
but is possible for the premium ads to remain on top after order? or to arrange themselves on top?

Let's see, is this what you want?:

Ordered by publishing date (default):

Most recent Premium
[more Premiums]
Oldest Premium
Most recent Normal
[more Normals]
Oldest Normal

Ordered by price (lowest to biggest):

Cheapest Premium
[more Premiums]
More expensive Premium
Cheapest Normal
[more Normals]
More expensive Normal

Ordered by price (biggest to lowest):

More expensive Premium
[more Premiums]
Cheapest Premium
More expensive Normal
[more Normals]
Cheapest Normal

Regards

geoo212

  • Newbie
  • *
  • Posts: 33
Re: (Solved) Premium Ads "Always on top" question
« Reply #9 on: January 10, 2015, 11:15:13 pm »
Hi,

@aide2001: i have osclass 3.5.0 and i used your code but isn't working.. Thanks a lot!

@teseo: Yes, this is what i want.

Thanks again, guys. :)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: (Solved) Premium Ads "Always on top" question
« Reply #10 on: January 11, 2015, 12:42:53 am »
***CORRECTED***

Hi,

Here it is:

1.- Add this at the very bottom of your theme functions.php:
Notes:
a.- Take care not to leave blank lines after this.
b.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function cust_all_premiums_ontop() {

    
$mSearch =  Search::newInstance();
    
$query_elements = (array) json_decode($mSearch->toJson());

    
$mSearch->order("b_premium desc, " $query_elements['order_column'], $query_elements['order_direction']);
}

osc_add_hook('search_conditions''cust_all_premiums_ontop');
?>


2.- To disable the normal block of premiums on the top of every search page, just comment this line in bender/search.php:

Code: [Select]
// osc_get_premiums();
Regards
« Last Edit: November 17, 2015, 05:37:08 pm by teseo »

geoo212

  • Newbie
  • *
  • Posts: 33
Re: (Solved) Premium Ads "Always on top" question
« Reply #11 on: January 11, 2015, 10:54:21 am »
Thanks so much, teseo! Everything works :)

Montekhristo

  • Special Agent
  • Full Member
  • *
  • Posts: 176
  • \m/ Rock n Roll yeahhh
Re: (Solved) Premium Ads "Always on top" question
« Reply #12 on: March 17, 2015, 06:23:13 pm »
@teseo, en 3.5.3 parece que no funciona.

Hi,

Here it is:

Code: [Select]
<?php
function cust_all_premiums_ontop() {

    
$mSearch =  Search::newInstance();
    
$query_elements = (array) json_decode($mSearch->toJson());

    
$mSearch->order("b_premium desc, " $query_elements['order_column'], $query_elements['order_direction']);
}

osc_add_hook('search_conditions''cust_all_premiums_ontop');
?>


Regards

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: (Solved) Premium Ads "Always on top" question
« Reply #13 on: March 17, 2015, 10:59:30 pm »
Hi

Just re-checked and everything's all right here, doing in search pages what is explained here... ???

Regards


786sujit

  • Newbie
  • *
  • Posts: 38
Re: (Solved) Premium Ads "Always on top" question
« Reply #14 on: October 17, 2015, 11:34:08 pm »
Hello Teseo,
                   I had tried the code you mentioned above, but it is having no effect for my website. I am using osClass 3.5.7 with default bender theme. I have no coding knowledge. Could you pls guide me regarding this .