Updated: Works with Osclass 3.0.2Hi all,
I've got a working plugin that's ready to be tested. It's called,
Popular Ads.
To use the plugin, there are two functions that must be called before and after your "most popular ads" section. The format is like this:
Basic structure:<?php popular_ads_start(); ?>
.... write your code here ....
<?php popular_ads_end(); ?>
The above code will basically load all data for the "popular ads" into a OSClass array, which can be accessed by the standard OSClass
Helper functions, here:
http://wiki.osclass.org/HItems.phpBasic Example:Here is a simple loop that will cycle through the entire array and display some information:
If you're wanting to try this plugin, this is a GREAT example to try! <?php popular_ads_start(); ?>
<?php if( osc_count_items() > 0) {
while ( osc_has_items() ) {
echo 'Item ID: '.osc_item_id().' Title: '.osc_item_title().' Views: '.osc_item_views().'<br>';
}
}
?>
<?php popular_ads_end(); ?>
Complete Working Example:This is a complete, working example taken directly from the "Latest Items" section on the Main page (I used BCute theme):
<?php popular_ads_start(); ?>
<div class="pop_ads">
<h1><strong><?php _e('Most Popular Ads', 'bcute') ; ?></strong></h1>
<?php if( osc_count_items() == 0) { ?>
<p class="empty"><?php _e('No Popular Ads', 'bcute') ; ?></p>
<?php } else { ?>
<table border="0" cellspacing="0">
<tbody>
<?php $class = "even"; ?>
<?php while ( osc_has_items() ) { ?>
<tr class="<?php echo $class. (osc_item_is_premium()?" premium":"") ; ?>">
<?php if( osc_images_enabled_at_items() ) { ?>
<td class="photo">
<?php if( osc_item_is_premium() ){ ?>
<div id="premium_img"></div>
<?php }?>
<?php if( osc_count_item_resources() ) { ?>
<a href="<?php echo osc_item_url() ; ?>">
<img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="75" height="56" title="" alt="" />
</a>
<?php } else { ?>
<a href="<?php echo osc_item_url() ; ?>">
<img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" alt="" title=""/>
</a>
<?php } ?>
</td>
<?php } ?>
<td class="text">
<div class="price-wrap"><span class="tag-head"></span><p class="price"><?php if( osc_price_enabled_at_items() ) echo osc_item_formated_price() ; ?></p></div>
<h3><a href="<?php echo osc_item_url() ; ?>"><?php echo osc_item_title() ; ?></a></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>
<?php $class = ($class == 'even') ? 'odd' : 'even' ; ?>
<?php } ?>
</tbody>
</table>
<?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 offers", 'modern'); ?> »</strong></a></p>
<?php } ?>
<?php } ?>
</div>
<?php popular_ads_end(); ?>
Within the plugin folder is a CSS file that should have all the needed CSS for the above example. Feel free to modify the CSS file for your own styling and format.
Set the number of ads to displayIn the admin panel, there is a Configuration page where you can set the desired number of popular ads to display.
Other notes:This is a work in progress, which means there could be bugs, snakes, alligators, bears and sheep hiding inside this plugin. Please feel free to report anything you feel isn't working correctly. It's possible that some Helper functions will not work. That is because I've not included every bit of item data into the array (I did my best to include ALL important data). Should this be the case, it's an easy fix.
Good luck my fellow OSClass'ers!