Osclass forums
Support forums => Tips, tricks, and tutorials => Topic started 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:
<?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.
-
I am using minimalist theme(Modern), could you guide me step-by-step how to insert this code for adsense ads between listings.
Thanks
-
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.-
// list regular ads
while(osc_has_items())
{
to:
// list regular ads
$adSense_middle_pos = ceil(osc_count_items()/2);
$ad_counter = 0;
while(osc_has_items())
{
2.-
<tr // etc
// [Normal code here]
?>
</tr>
This translates on vanilla Minimalist as:
<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(), false, true);
?>
</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:
<?php
$class = ($class == 'even') ? 'odd' : 'even';
}
?>
with:
<?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
-
8)
-
***UPDATED***
For Bender you need to modify oc-content/themes/bender/loop.php
This block at the end of the script:
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:
$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
-
Thanks teseo, you are dependable!
-
Hi can anyone help me with this using infinity theme?
-
follow teseos advice. infinity theme is based on bender.
-
Hi Sorry still having problems
adsence doesn't show for me
here is my stock 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');
}
?>
<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%3 == 0){
$class = 'first';
}
infinity_draw_item($class);
$i ;
}
} elseif($type == 'premiums'){
while ( osc_has_premiums() ) {
$class = '';
if($i%3 == 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%4 == 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
<?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%3 == 0){
$class = 'first';
}
infinity_draw_item($class);
$i ;
}
} elseif($type == 'premiums'){
while ( osc_has_premiums() ) {
$class = '';
if($i%3 == 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%4 == 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? :-[
-
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
-
Hi Teseo,
either Im blind or stupid or both but I have changed that line and still nothing shows.. long day lol :-[
-
***UPDATED***
For Infinity you need to modify oc-content/themes/infinity/loop.php
This block:
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:
$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
-
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
<?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>»</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>»</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
-
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:
<?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:
<?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>»</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:
<?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>»</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,
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:
<?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:
<?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>»</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:
<?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>»</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
-
Will this work for any banner ad setup or is it just for adsense banners?
-
you can use it with different banners
-
In fact, you can put there whatever you want. Hey, why not a premium ad? ???
Regards
-
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
-
This code is programmed to show 1 banner in the middle:
$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:
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
-
Wow, this is amazing. Many thanks for all the light and dispensed code. :)
Regards
-
wow...i love this tutt...
can you show me how to add this to this theme?
Symnel - Free Responsive Osclass Theme
Thanks in advance!
-
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
-
ok then...
Thanks...
-
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.
-
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
-
Hi, I added code, but banner not showing. Can anyone help me? I'm using Celio Theme (like Infinity theme) This is my code:
<?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%3 == 0){
$class = 'first';
}
celio_draw_item($class);
$i ;
}
} elseif($type == 'premiums'){
while ( osc_has_premiums() ) {
$class = '';
if($i%3 == 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%4 == 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>
-
whats your site.
-
www.cbay.it (http://www.cbay.it)
-
so?
-
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?
-
ok. do you this is compatible?
-
no one want help me????
-
nice website looks good.
-
any modification code for TuffClassified theme???
-
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>
-
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:
} 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:
} 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
-
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!
-
Hi,
Yes, each theme can have a different HTML structure. This should work for Twitter:
search-list.php:
1.- Look for this line:
<?php while ( osc_has_items() ) { ?>
and replace it with:
<?php $adSense_middle_pos = ceil(osc_count_items()/2);
$ad_counter = 0;
while ( osc_has_items() ) { ?>
2.- Replace:
<?php } ?>
<?php } ?>
<div class="pagination">
with:
<?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
-
Thank you Teseo!
It worked like charm. Happy happy happy :)
-
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?
-
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
} 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
} 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..
-
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
-
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
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_highlight( strip_tags( osc_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_highlight( strip_tags( osc_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_highlight( strip_tags( osc_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_highlight( strip_tags( osc_item_description() ) ); ?></p> <?php } ?>
</div>
</div>
<?php $class = ($class == 'even') ? 'odd' : 'even'; ?>
<?php if( $i == 5 ) { ?>
</tbody>
</table>
<?php osc_run_hook('search_ads_listing_medium1'); ?>
<table border="0" cellspacing="0">
<tbody>
<?php } ?>
<?php } ?>
</tbody>
</table>
-
Hi,
I don't know that theme but seems that could be done this way:
1.- Replace:
<?php while(osc_has_items()) { $i++; ?>
with:
<?php $adSense_middle_pos = ceil(osc_count_items()/2);
while(osc_has_items()) { $i++; ?>
2.- Replace:
<?php $class = ($class == 'even') ? 'odd' : 'even'; ?>
with:
<?php if ($i+1 == $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
-
WORKED LIKE A CHARM!! THanks!!!!
Hi,
I don't know that theme but seems that could be done this way:
1.- Replace:
<?php while(osc_has_items()) { $i++; ?>
with:
<?php $adSense_middle_pos = ceil(osc_count_items()/2);
while(osc_has_items()) { $i++; ?>
2.- Replace:
<?php $class = ($class == 'even') ? 'odd' : 'even'; ?>
with:
<?php if ($i+1 == $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
-
You're welcome. :) Could you tell me to which file of Royal theme belongs the code you pasted here?
Regards
-
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
-
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
-
Hi,
What theme is that and where can I see a demo? ???
Regards
-
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
-
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
<?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 */
}
?>
-
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 ?
-
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
-
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.
-
how to on Boxer theme??
-
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.
-
Any updates on gallery view option? :D
-
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?
-
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
-
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...
-
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?
-
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?
-
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]
-
I think is a modified version of infinity theme, but i think is no more available on osclass market.
-
I think is a modified version of infinity theme, but i think is no more available on osclass market.
Sadly so it seems..... :-[
-
i want to add absent code in search page for veronika theme , how can i do? please help me,
this is loop-single.php
-
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
<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_highlight( strip_tags( osc_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()!='' ) { ?>·
<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_highlight( strip_tags( osc_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()!='' ) { ?>·
<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+1 == $adSense_middle_pos) {
//AdSense middle ?>
<div class="list-product news reguler">
// [Specific AdSense code here]
</div>
<?php }
-
Has anyone applied this to OsclassWizards theme ?
-
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...?
-
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?
-
Hi,
Has anyone applied this to OsclassWizards theme ?
For Osclass Wizards you need to modify oc-content/themes/osclasswizards/loop-search-list.php
1.-
else {
while (osc_has_items()) {
Replace with:
else {
$adSense_middle_pos = ceil(osc_count_items() / 2);
$ad_counter = 0;
while (osc_has_items()) {
2.- And, at the end of the script:
<?php
}
}
?>
</ul>
Replace with:
<?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
-
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
-
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?
-
I can't help you, I don't have that theme.
Regards
-
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,
-
I finally managed to make it work in Infinity, but how do I apply this also for home page (latest items)?
Thanks. ;)
-
Sorry, I don't have access to any installation using Infinity theme anymore.
Regards
-
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.
-
OK.
For Latest Listings on Bender you need to modify oc-content/themes/bender/loop.php
This block:
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:
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
-
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'
-
How to do same in Osclass Wizards theme?
-
Hi,
For Osclass Wizards, see here:
https://forums.osclass.org/tips-and-tricks/(tip)-ads-between-listings/msg157104/#msg157104
Regards
-
<?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
-
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?
-
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.
-
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.
-
anyone please :'(
-
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
-
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
<?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) { ?>
-
Thanks alot !!
I had managed to resolve it ...