Advertisement:

Author Topic: How to put a preview of the ad in the makepremium page?  (Read 2250 times)

brenosilver

  • Newbie
  • *
  • Posts: 21
How to put a preview of the ad in the makepremium page?
« on: October 16, 2013, 07:00:06 am »
Hi, i'm trying to put a preview in the makepremium.php page of how the ad is going to look like after the purchase of Premium.  However I can't get it to work.
I'm new to osclass and php overall, so i'm those people that copy and paste code.  Thus I tried this and it obviously didn't work (i was just trying to see if I got any results at all).
Code: [Select]
<?php if(osc_count_items() > 0) { ?>
     <ul class="listing-card-list <?php echo $listClass?>" id="listing-card-list">
          <?php
          $i 
0;
          while(
osc_has_items()) { $i++; ?>

<?php if(!(osc_item_is_premium())) { ?> <!--Breno Mod Don't show dupplicate when Premium-->
                 <?php
                 $class 
false;
                 if(
$i%== 0){
                    
$class 'last';
                 }
                 
bender_draw_item($class); ?>

<?php ?>
          <?php ?>
     </ul>
 <?php ?>

As I wasn't getting any results I tried the premium code:

Code: [Select]
        <?php
            $i 
0;
            
osc_get_premiums();
            if(
osc_count_premiums() > 0) {
                
//echo '<h5>Premium listings</h5>';
                
echo '<ul class="listing-card-list '.$listClass.' premium-list" id="listing-card-list">';
                while ( 
osc_has_premiums() ) {
                    
$class '';
                    if(
$i%== 0){
                        
$class 'first';
                    }
                    
bender_draw_item($class,false,true);
                    
$i++;
                    if(
$i == 3){
                        break;
                    }
                }
                echo 
'</ul>';
            }
        
?>

I was more lucky with that, it returned the premium ads, I guess it's because of the osc_get_premiums()? but I don't want premium, and I saw that there is no similar function for non-premium ads.

I could always get the resources one by one and style them by hand, but I think that wouldn't be efficient.

Could someone give me a hand on how to query this?I don't really need a loop like I have in the code, just the item to be Premium is enough.

I really appreciate for your time.

thank you!
« Last Edit: October 16, 2013, 07:07:55 am by brenosilver »

brenosilver

  • Newbie
  • *
  • Posts: 21
Re: How to put a preview of the ad in the makepremium page?
« Reply #1 on: October 16, 2013, 09:04:08 pm »
Ok I got it =)

Code: [Select]
<?php
$items        Item::newInstance()->findByUserIDEnabled($_SESSION['userId']);
View::newInstance()->_exportVariableToView('items'$items);
?>


<?php if(osc_count_items() > 0) { ?>
<ul class="listing-card-list '.$listClass.' premium-list" id="listing-card-list">
<?php
while(osc_has_items()) { 

if(osc_item_id() == $item['pk_i_id']){
$class '';
bender_draw_item($class); } 
?>

</ul>
<?php ?>


I just have one problem, when the person is not logged in findByUserIDEnabled doesn't retrieve anything. What function should I use instead of that?

Thank you.
« Last Edit: October 16, 2013, 09:11:29 pm by brenosilver »

Hello

  • Full Member
  • ***
  • Posts: 174
Re: How to put a preview of the ad in the makepremium page?
« Reply #2 on: October 16, 2013, 10:16:13 pm »
pls upload inage how its looks

brenosilver

  • Newbie
  • *
  • Posts: 21
Re: How to put a preview of the ad in the makepremium page?
« Reply #3 on: October 16, 2013, 10:46:32 pm »
pls upload inage how its looks

It looks just like a Premium ad in the search page. instead of white background it is yellowish.

brenosilver

  • Newbie
  • *
  • Posts: 21
Re: How to put a preview of the ad in the makepremium page?
« Reply #4 on: October 19, 2013, 09:12:04 am »
Allright I got it working for non logged users.  I find the documentation very vague and I catch myself learning by try and error. But hey, at least i'm moving forward.

There is probably a better way to do this, but that is what I got so far.

Code: [Select]

<?php
$items Item::newInstance()->findByPrimaryKey($item['itemid']);
array_push($items$item);
View::newInstance()->_exportVariableToView('items'$items);
?>


<?php 
$count 0;
if(osc_count_items() > 0) { ?>

<ul class="listing-card-list '.$listClass.' premium-list" id="listing-card-list">
<?php while(osc_has_items()) { 
if(osc_item_id() == $item['pk_i_id']){
$count++;
$class '';
bender_draw_item($class); 
if($count >= 1){
break;
}

?>

</ul>
<?php ?>