Osclass forums
Support forums => Plugins => Plugin Payments => Topic started by: brenosilver 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).
<?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%4 == 0){
$class = 'last';
}
bender_draw_item($class); ?>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
As I wasn't getting any results I tried the premium code:
<?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%3 == 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!
-
Ok I got it =)
<?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.
-
pls upload inage how its looks
-
pls upload inage how its looks
It looks just like a Premium ad in the search page. instead of white background it is yellowish.
-
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.
<?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 } ?>