Google Adsense with...
 
Notifications
Clear all

[Solved] Google Adsense with Osclass 3.9

14 Posts
2 Users
2 Reactions
280 Views
(@philipps)
Posts: 4
Active Member
Topic starter
 

Hi guys.

I run an Osclass 3.9 for a while and last year the hits picked up. So i want to monetize that traffic to cover my expenses of running a free community-serving classifieds site. And Google Adsense is the easiest way for me.

So i tried several things. Google Adsense auto-ads at first but that filled my site with ugly ads everywhere, in huge sizes and i do not want that.

Then i tried to use the theme's (Osclasswizards) advertizing spaces and worked ok. BUT didn't give me the options i wanted and created a few issues, like showing ads in register and login and new ads posting. Some are prohibited from adsense ( like login/register).

Is there any other relatively easy way to server google adsense ads? A plugin? Or whatever?

Thank you

 
Posted : January 9, 2022 18:35
Topic Tags
Maximus
(@maximus)
Posts: 57
Reputable Member
 

Hi.

I can assist in this IF you have some very very basic knowledge of php and how to change a few things here and there.

Like adding some code or change some.

 
Posted : January 9, 2022 19:10
(@philipps)
Posts: 4
Active Member
Topic starter
 

@maximus I'm not a developer but i can't do some changes or add some code in the php files. I have done that already to remove some things i didn't wanted to be available to visitors.

In any case, i'm willing to try and see how it goes.

 
Posted : January 9, 2022 21:27
Maximus
(@maximus)
Posts: 57
Reputable Member
 

STEP 1:

ok, before anything else, enable debug to a log, to be sure you have (or will have after the changes) any issues.

In config.php insert:

 

define('OSC_DEBUG', true) ;
define('OSC_DEBUG_LOG', true) ;

 

All the changes are done in your theme and nowhere else, so make a BACKUP of your theme before doing anything else.

Also some code is added to your config.php but this easily removed (commented out) in case of trouble.

 
Posted : January 9, 2022 22:09
Maximus
(@maximus)
Posts: 57
Reputable Member
 

Add this to your config.php

 

//
//* Ads Definitions */

define ('GOOGLE_ADS_MAIN_TOP', false) ; // Main Below Categories
define ('GOOGLE_ADS_LATEST', true) ; // Main Latest Listings Top
define ('GOOGLE_ADS_POPULAR', true) ; // Main Popular in ...
define ('GOOGLE_ADS_RELATED', true) ; // Items Related
define ('GOOGLE_ADS_ITEMS_SIDEBAR', true) ; // Items Sidebar
define ('GOOGLE_ADS_SEARCH_TOP', true) ; // Categories & Search TOP
define ('GOOGLE_ADS_SEARCH_BOTTOM', true) ; // Categories & Search BOTTOM
define ('GOOGLE_ADS_8', false) ; // Unused
define ('GOOGLE_ADS_9', false) ; // Unused
define ('GOOGLE_ADS_10', false) ; // Unused

//
//

 

While the above is pretty easy to understand, this is only what I use. You may not use all of them, disable some (false) or add your own.

I will post the code for each of the files to change, "main.php", item.php", search.php" and "item-sidebar.php".

 
Posted : January 9, 2022 22:32
Maximus
(@maximus)
Posts: 57
Reputable Member
 

STEP 3:

Those are the changes in my "main.php":

 

<?php osc_run_hook('inside-main'); ?>
<div class="content">
  <div class="title">
    <h1>
      <?php _e('Latest Listings', OSCLASSWIZARDS_THEME_FOLDER) ; ?>
     
	  </h1>
  </div>
  
<?php if (GOOGLE_ADS_LATEST == "true") { ?>

  <div class="ads_header ads-headers">

Your Adsense Script Here

  </div>

<?php } ?>
 
  <div class="latest_ads">
    <?php if( osc_count_latest_items() == 0) { ?>
    <p class="empty">
      <?php _e("There aren't listings available at this moment", OSCLASSWIZARDS_THEME_FOLDER); ?>
    </p>
    <?php } else { ?>
    <?php
    View::newInstance()->_exportVariableToView("listType", 'latestItems');
    View::newInstance()->_exportVariableToView("listClass",$listClass);
	osc_current_web_theme_path($loop_template);
    ?>
    <?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', OSCLASSWIZARDS_THEME_FOLDER) ; ?>
      &raquo;</strong></a> </p>
    <?php } ?>
    <?php } ?>
  </div>
  <?php if(osc_get_preference('show_popular', 'osclasswizards_theme') == '1'){?>
  <div id="tab_filter">
    <h2 class="title"> <?php echo sprintf(__('Popular in %s', OSCLASSWIZARDS_THEME_FOLDER), osc_page_title()) ; ?> </h2>
	
<?php if (GOOGLE_ADS_POPULAR == "true") { ?>

  <div class="ads_header ads-headers">

	Your Adsense Script Here

  </div>

<?php } ?>
	
    <?php if(osclasswizards_show_popular_searches() ){ ?>
 
Posted : January 9, 2022 22:42
Maximus
(@maximus)
Posts: 57
Reputable Member
 

Just let me know if you understand what you must change or add.

The above is part of MY "main.php". You do not need to change all that, just to add

 

<?php if (GOOGLE_ADS_LATEST == "true") { ?>

  <div class="ads_header ads-headers">

Your Adsense Script Here

  </div>

<?php } ?>

and

<?php if (GOOGLE_ADS_POPULAR == "true") { ?>

  <div class="ads_header ads-headers">

	Your Adsense Script Here

  </div>

<?php } ?>

The rest is for you to understand WHERE to inject those.

 
Posted : January 9, 2022 22:44
Page 1 / 2