Advertisement:

Author Topic: [TIP] premiums rotating on page refresh  (Read 1963 times)

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
[TIP] premiums rotating on page refresh
« on: October 07, 2013, 09:00:12 pm »
this is teseo's (my hero!!)...  I tweaked it to work in the premium loop. for bender. osclass 3.2.1

replace all in premium loop


Code: [Select]
<?php $size explode('x'osc_thumbnail_dimensions()); ?>
<?php
    $i
=1;
    
$x=1;
    
$class "even" ;
        
$counter 1;
        
$random_number rand(1osc_count_premiums()); ?>

<li class="listing-card <?php echo $class?> premium">
    <?php if( osc_images_enabled_at_items() ) { ?>
   
        <?php if(osc_count_premium_resources()) { ?>
            <a class="listing-thumb" href="<?php echo osc_premium_url() ; ?>" title="<?php echo osc_premium_title() ; ?>"><img src="<?php echo osc_resource_thumbnail_url(); ?>" title="" alt="<?php echo osc_premium_title() ; ?>" width="<?php echo $size[0]; ?>" height="<?php echo $size[1]; ?>"></a>
        <?php } else { ?>
            <a class="listing-thumb" href="<?php echo osc_premium_url() ; ?>" title="<?php echo osc_premium_title() ; ?>"><img src="<?php echo osc_current_web_theme_url('images/no_photo.gif'); ?>" title="" alt="<?php echo osc_premium_title() ; ?>" width="<?php echo $size[0]; ?>" height="<?php echo $size[1]; ?>"></a>
        <?php ?>
    <?php ?>
    <div class="listing-detail">
        <div class="listing-cell">
            <div class="listing-data">
                <div class="listing-basicinfo">
                    <a href="<?php echo osc_premium_url() ; ?>" class="title" title="<?php echo osc_premium_title() ; ?>"><?php echo osc_premium_title() ; ?></a>
                    <div class="listing-attributes">
                        <span class="category"><?php echo osc_premium_category() ; ?></span> -
                        <span class="location"><?php echo osc_premium_city(); ?> (<?php echo osc_premium_region(); ?>)</span> <span class="g-hide">-</span> <?php echo osc_format_date(osc_premium_pub_date()); ?>
                        <?php if( osc_price_enabled_at_items() ) { ?><span class="currency-value"><?php echo osc_premium_currency_symbol(), osc_format_price(osc_item_price()); ?></span><?php ?>
                    </div>
                    <p><?php echo osc_highlightstrip_tagsosc_premium_description()) ,250) ; ?></p>
                </div>
                <?php if($admin){ ?>
                    <span class="admin-options">
                        <a href="<?php echo osc_premium_edit_url(); ?>" rel="nofollow"><?php _e('Edit item''bender'); ?></a>
                        <span>|</span>
                        <a class="delete" onclick="javascript:return confirm('<?php echo osc_esc_js(__('This action can not be undone. Are you sure you want to continue?''bender')); ?>')" href="<?php echo osc_premium_delete_url();?>" ><?php _e('Delete''bender'); ?></a>
                        <?php if(osc_premium_is_inactive()) {?>
                        <span>|</span>
                        <a href="<?php echo osc_premium_activate_url();?>" ><?php _e('Activate''bender'); ?></a>
                        <?php ?>
                    </span>
                <?php ?>
                    <?php $class = ($class == 'even') ? 'odd' 'even' ?>
            </div>
        </div>
    </div>
</li>
« Last Edit: October 16, 2013, 11:36:36 pm by design »

Hello

  • Full Member
  • ***
  • Posts: 174
Re: [TIP] premiums rotating on page refresh
« Reply #1 on: October 17, 2013, 10:56:06 am »
its already working on bender theme

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [TIP] premiums rotating on page refresh
« Reply #2 on: October 17, 2013, 06:48:28 pm »
I wanted only a single premium rotating object that I can place anywhere on the site.... and style it as needed.

and this little gem does it :-)

InstaladorX

  • Full Member
  • ***
  • Posts: 109
  • I live without rest! Osclass 3.2.1 Theme Bender
Re: [TIP] premiums rotating on page refresh
« Reply #3 on: November 21, 2013, 08:10:46 am »
Hi,
So what is the usefulness of these variables?

Code: [Select]
$i=1;
         $x=1;

I can not see the purpose for them this code.

You have another part of the code that is not here?

 8) Go beyond!

design

  • Hero Member
  • *****
  • Posts: 2619
  • Osclass 3.5 MAC/PC w/ Modern Browsers
Re: [TIP] premiums rotating on page refresh
« Reply #4 on: November 21, 2013, 06:27:31 pm »
 I do not know how any of this works, I just know it does. You are welcome to ask Teseo  ;)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [TIP] premiums rotating on page refresh
« Reply #5 on: November 21, 2013, 06:48:00 pm »
Well, I'd swear that part is not mine. :D Looking at the code you sent me via PM a while ago, I'd say it seems some kind of a mechanism to have groups of 4. ??? This is the complete code:

Code: [Select]
<?php osc_get_premiums(1000);

if(
osc_count_premiums()>0) { ?>

<?php
    $i
=1;
    
$x=1;
    
$class "even" ;
        
$counter 1;
        
$random_number rand(1osc_count_premiums()); ?>

        <div class="premium">
    <div class="premium_<?php echo $class?>">
      <?php while(osc_has_premiums()) {
        if (
$counter == $random_number) {  ?>

        <?php if( osc_images_enabled_at_items() ) { ?>
            <h3 class="text">
                <?php _e("Sponsored ad""bender"); ?>
                </h3>
            <div class="photo">

                <?php if(osc_count_premium_resources()) { ?>
                <a href="<?php echo osc_premium_url() ; ?>"><img src="<?php echo osc_resource_url() ; ?>" width="100%" height="100%" title="<?php echo osc_premium_title() ; ?>" alt="<?php echo osc_premium_title() ; ?>" /></a>
                <?php } else { ?>
                <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" title="" alt="" />
                <?php ?>
            </div>
            <?php ?>
            <p class="tag-text"><?php _e("Ad listed in""bender"); ?>&nbsp;<a href="<?php echo osc_search_category_url() ; ?>"><?php echo osc_premium_category() ; ?></a>
        <h3> <span class="text"><a href="<?php echo osc_premium_url() ; ?>"><?php echo osc_premium_title() ; ?></a></span> </h3>
        <p class="text"> <?php echo osc_premium_city(); ?> (<?php echo osc_premium_region(); ?>)</p>
        <p class="text"><?php echo osc_highlightstrip_tagsosc_premium_description() ) ,100) ; ?></p>
        <?php $class = ($class == 'even') ? 'odd' 'even' ?>
        <?php
        
if($i == 4) {

            
$i 1;
            echo 
'</tr>';
            if (
$x osc_count_premiums()){
                echo <
tr class="premium_<?php echo $class; ?>
">';
            }
        } else {
            $i++;
        }
        $x++;
        ?>
        <?php break; } else { $counter++ ; }
    } 
?>

    <?php ?>

Regards