Advertisement:

Author Topic: Show Premium Ads only on HomePage  (Read 5945 times)

786sujit

  • Newbie
  • *
  • Posts: 38
Show Premium Ads only on HomePage
« on: November 12, 2015, 07:37:45 pm »
Hello everybody,

I am using OSClass 3.5.7 with Bender Theme.

How can I make it show Premium Ads on top and then show Latest listings below, on the website homepage (Just like we see in search results).
OR
How can I make it show only Premium Ads on home page and NO Latest listings.

Thanks.

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #1 on: November 14, 2015, 01:05:24 am »
Hello,
         I have somehow managed to get Premium Listings on homepage, by comparing codes and reading threads from this forum .
I am pasting my entire main.php code here. Pls can somebody check and tell me if this code alteration will work smooth in the long run OR will interfere with other functioning of the website. PLS ...

main.php :-

<?php
    /*
     *      Osclass – software for creating and publishing online classified
     *                           advertising platforms
     *
     *                        Copyright (C) 2014 OSCLASS
     *
     *       This program is free software: you can redistribute it and/or
     *     modify it under the terms of the GNU Affero General Public License
     *     as published by the Free Software Foundation, either version 3 of
     *            the License, or (at your option) any later version.
     *
     *     This program is distributed in the hope that it will be useful, but
     *         WITHOUT ANY WARRANTY; without even the implied warranty of
     *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *             GNU Affero General Public License for more details.
     *
     *      You should have received a copy of the GNU Affero General Public
     * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */

    // meta tag robots
    osc_add_hook('header','bender_follow_construct');

    bender_add_body_class('home');


    $buttonClass = '';
    $listClass   = '';
    if(bender_show_as() == 'gallery'){
          $listClass = 'listing-grid';
          $buttonClass = 'active';
    }
?>
<?php osc_current_web_theme_path('header.php') ; ?>
<div class="clear"></div>
<div class="latest_ads">

<!--From here Premium Listings code begins -->

<h1><strong><?php _e('Premium Listings', 'bender') ; ?></strong></h1>

<?php if( osc_count_premiums() == 0) { ?>
    <div class="clear"></div>
    <p class="empty"><?php _e("No Premium listings available at this moment", 'bender'); ?></p>
<?php } else { ?>

<div class="actions">
      <span class="doublebutton <?php echo $buttonClass; ?>">
           <a href="<?php echo osc_base_url(true); ?>?sShowAs=list" class="list-button" data-class-toggle="listing-grid" data-destination="#listing-card-list"><span><?php _e('List', 'bender'); ?></span></a>
           <a href="<?php echo osc_base_url(true); ?>?sShowAs=gallery" class="grid-button" data-class-toggle="listing-grid" data-destination="#listing-card-list"><span><?php _e('Grid', 'bender'); ?></span></a>
      </span>
    </div>
   
<?php
            $i = 0;
            osc_get_premiums(100);
            if(osc_count_premiums() > 0) {
            View::newInstance()->_exportVariableToView("listType", 'premiums');
            View::newInstance()->_exportVariableToView("listClass",$listClass.' premium-list');
            osc_current_web_theme_path('loop.php');
            echo '<div style="clear:both;"></div><br/>';
            }
        ?>
<!-- From here Latest Listings code begins -->   
   
<h1><strong><?php _e('Latest Listings', 'bender') ; ?></strong></h1>
     
    <?php
    View::newInstance()->_exportVariableToView("listType", 'latestItems');
    View::newInstance()->_exportVariableToView("listClass",$listClass);
    osc_current_web_theme_path('loop.php');
    ?>
    <div class="clear"></div>
    <?php if( osc_count_latest_items() == osc_max_latest_items() ) { ?>
        <p class="see_more_link"><a href="<?php echo osc_search_show_all_url() ; ?>">
            <strong><?php _e('See all listings', 'bender') ; ?> &raquo;</strong></a>
        </p>
    <?php } ?>
<?php } ?>
</div>
</div><!-- main -->
<div id="sidebar">
    <?php if( osc_get_preference('sidebar-300x250', 'bender') != '') {?>
    <!-- sidebar ad 350x250 -->
    <div class="ads_300">
        <?php echo osc_get_preference('sidebar-300x250', 'bender'); ?>
    </div>
    <!-- /sidebar ad 350x250 -->
    <?php } ?>
    <div class="widget-box">
        <?php if(osc_count_list_regions() > 0 ) { ?>
        <div class="box location">
            <h3><strong><?php _e("Location", 'bender') ; ?></strong></h3>
            <ul>
            <?php while(osc_has_list_regions() ) { ?>
                <li><a href="<?php echo osc_list_region_url(); ?>"><?php echo osc_list_region_name() ; ?> <em>(<?php echo osc_list_region_items() ; ?>)</em></a></li>
            <?php } ?>
            </ul>
        </div>
        <?php } ?>
    </div>
</div>
<div class="clear"><!-- do not close, use main clossing tag for this case -->
<?php if( osc_get_preference('homepage-728x90', 'bender') != '') { ?>
<!-- homepage ad 728x60-->
<div class="ads_728">
    <?php echo osc_get_preference('homepage-728x90', 'bender'); ?>
</div>
<!-- /homepage ad 728x60-->
<?php } ?>
<?php osc_current_web_theme_path('footer.php') ; ?>

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Show Premium Ads only on HomePage
« Reply #2 on: November 14, 2015, 01:22:12 am »
Hi,

Seems fine to me, congratulations. :)

Regards

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #3 on: November 14, 2015, 05:45:53 pm »
Hello Teseo,
                  Thanks for response and valued time. I really feel greedy to ask you questions.

Initially on my website, when I used to choose ad sorting type in search results, it would reflect in both Premium and Normal listings. But since some days ago, the ad sorting in search results is reflecting only for Normal Listings. Premium ads in search results are having no effect upon it. Check attachment.



                 I guess this happened since my following changes to websites :-

# When I changed the code in loop.php and search.php to show more premium ads than the default.
   I did this by reading this thread = http://forums.osclass.org/development/display-more-than-2-premium-ads/
   
# Installed, used, uninstalled & then deleted the plugin "More Edit"
   Downloaded from here = http://market.osclass.org/plugins/ad-management/more-edit_23

# And this is the list of the installed plugins on my website :-
Admin search email
Admin tools login
Butler
Contact counter
Google Analytics
Google Maps
Nomore Copypaste Plugin
Payment system
Rich edit
SEO Wiz
Sitemap Generator
Voting

Teseo can you pls guide and help me, so that Premium and Normal listings both get sorted accordingly the option selected, as it used to be when I had newly installed OSClass 3.5.7 Bender for my website SolapurAds.com

THANKS.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Show Premium Ads only on HomePage
« Reply #4 on: November 14, 2015, 07:28:00 pm »
Initially on my website, when I used to choose ad sorting type in search results, it would reflect in both Premium and Normal listings.

Maybe you thought so, but the thing is that normal Premiums mechanism has its own order (By number of times each one has been shown at the top of the search list. Less shown take precedence, this is to keep balance between them). So no matter what Order you pick, Premiums aren't affected by it.

Regards

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #5 on: November 14, 2015, 11:07:23 pm »
THANKS Teseo for the response,
                      After reading this thread http://forums.osclass.org/general-help/premium-ads-not-listed-randomly/15/
                      I think the Premium ads randomization is not working on my website too.

Couple of more questions, pls answer :-

1.
                      For OSClass 3.5.7 Bender theme, How can I make it show like you mentioned here 
http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113934/#msg113934

------------------------------------------------------------------------------------------------------------------------------------

2.

I have made changes in main.php and search.php to this code line
(osc_get_premiums(100);) for Homepage
 AND
(osc_get_premiums(12);) for Search results
     
Is it Ok & Safe to keep like this i.e. Show 100 Premiums on homepage & 12 Premiums show in search or category results.

------------------------------------------------------------------------------------------------------------------------------------

Thank you.
« Last Edit: November 14, 2015, 11:27:10 pm by 786sujit »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Show Premium Ads only on HomePage
« Reply #6 on: November 15, 2015, 02:00:51 pm »
1.
                      For OSClass 3.5.7 Bender theme, How can I make it show like you mentioned here 
http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113934/#msg113934

Is there, the code in this post:

http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113951/#msg113951

But first read the general instructions:

http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113814/#msg113814

------------------------------------------------------------------------------------------------------------------------------------

Quote
2.

I have made changes in main.php and search.php to this code line
(osc_get_premiums(100);) for Homepage
 AND
(osc_get_premiums(12);) for Search results
     
Is it Ok & Safe to keep like this i.e. Show 100 Premiums on homepage & 12 Premiums show in search or category results.

I see no problems, excepting that if you want to apply my function cust_all_premiums_ontop() you need to get rid of this "(osc_get_premiums(12);) for Search results" or Premiums will be duplicated.

Regards

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #7 on: November 15, 2015, 07:02:44 pm »
Hello Teseo,
                  THANKS once again. I really appreciate for your valued time and guidance.

I have successfully implemented your code to get the Premium ads displayed first and then Normal listings with sort ordering effective in the search results.

Just wanted to enquire this. Now will all the premium ads of that particular category get displayed in search results OR just few premiums , as it used to be by default ?

-----------------------------------------------------------------------------------------------------------------------------------------------

For the home page I have put the following code in main.php , to show 100 Premium ads and then show  Latest listings.
<?php
            $i = 0;
            osc_get_premiums(100);
            if(osc_count_premiums() > 0) {
            View::newInstance()->_exportVariableToView("listType", 'premiums');
            View::newInstance()->_exportVariableToView("listClass",$listClass.' premium-list');
            osc_current_web_theme_path('loop.php');
            echo '<div style="clear:both;"></div><br/>';
            }
?>

Note :- Can refer the complete main.php file code at top of this post.

Can you give me a code for the main.php (Homepage) by which all the existing Premium ads on the website gets displayed , instead of the defined 100 premiums.

It should show like this on homepage  =

All Categories links (its available by default in OSClass)
All Premium Listings of the website
12 Latest listings
See All Listings (Link) 
etc.
« Last Edit: November 15, 2015, 07:08:07 pm by 786sujit »

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #8 on: November 15, 2015, 07:09:32 pm »
This post was posted by mistake. Pls ignore this and refer the previous post . ???
« Last Edit: November 15, 2015, 07:15:23 pm by 786sujit »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Show Premium Ads only on HomePage
« Reply #9 on: November 15, 2015, 07:51:35 pm »
Quote
Can you give me a code for the main.php (Homepage) by which all the existing Premium ads on the website gets displayed , instead of the defined 100 premiums
.

Just use osc_get_premiums with some impossible number, like: osc_get_premiums(1000000);

Quote
Now will all the premium ads of that particular category get displayed in search results OR just few premiums , as it used to be by default ?

No, if you use osc_get_premiums function, always all balanced, no category taken into consideration.

Another function to sort Premiums with custom order would need to be built. Give me a couple of days and I'll get back with something. ;)

Regards

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #10 on: November 15, 2015, 11:33:51 pm »
Hello Teseo, THANKS for response.
                 
I have inserted the following code in functions.php,


<!--Teseo 2nd code-->

<?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');
?>


 
to get search result like mentioned here = http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113934/#msg113934

-----------------------------------------------------------------------------------------------------------------------------------------------

                                                                         Actually I mean to ask this :-


Assume that I have clicked "For sale" category on the homepage.

A result page will get opened, showing Premium ads and then below some Normal ads. pls refer attachment

Here on this page does all the Premium ads from the "For sale" category gets displayed
 OR
Only few Premium ads from the "For sale" category gets displayed (randomly chosen by OSClass)?
« Last Edit: November 15, 2015, 11:48:44 pm by 786sujit »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Show Premium Ads only on HomePage
« Reply #11 on: November 17, 2015, 01:37:19 pm »
Hi again,

I've been looking into this, but I'm a bit lost at this point... :D Could you write down what do you want exactly? ???

Regards

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #12 on: November 17, 2015, 03:40:27 pm »
Hello Teseo,
                  I am really sorry for the confusion. Actually I am unable to properly express myself due to over excitement.
my question was related to category search result.

I intention is to make All the Premium Ads more visible everywhere on website.

-----------------------------------------------------------------------------------------------------------------------------------

Could you guide me , how can I make three different slide show of size 300x300 for the following :-
1. Premium ads
2. Latest ads
3. Custom ads
which can be placed on the sidebar (refer attachment)

Thanks.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Show Premium Ads only on HomePage
« Reply #13 on: November 17, 2015, 05:43:58 pm »
Let's see, about your original question, please re-check this post:

http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113951/#msg113951

Mind I've added a 2nd point to disable normal Premiums block. Using that code you can achieve this:

Code: [Select]
Here on this page does all the Premium ads from the "For sale" category gets displayed
And the slideshow thing, sorry, but that's way too far of the matter at hand. Look in the forum for some slider plugin and once you get it working, if you want to change its default content (type of ads being shown) then I could help with that.

Regards

786sujit

  • Newbie
  • *
  • Posts: 38
Re: Show Premium Ads only on HomePage
« Reply #14 on: November 17, 2015, 07:12:34 pm »
Hello Teseo,
                  Regarding my original question (http://forums.osclass.org/general-help/premium-ads-'always-on-top'-question/msg113951/#msg113951) I had already put the codes correctly & everything seems to be working fine.
I have not used the 2nd code   // osc_get_premiums();   but amazingly no premiums are re-displayed on the next page.

At present I have only 13 ads overall on the website (with total 6 premiums).
Hence unable to understand that, will all the premiums from that particular category will get displayed on the respective search results 1st page.

-----------------------------------------------------------------------------------------------------------------------------------------------

I soon will test the slider plugin which I got from this forum, and let you know how it goes.

A big THANKS to you, for your co-operative nature. You are truly intelligent with generous heart.

-----------------------------------------------------------------------------------------------------------------------------------------------


 
« Last Edit: November 17, 2015, 07:24:38 pm by 786sujit »