on :September 21, 2019, 4:44 pm #25
I have a question regarding programming using "continue" statement
The code is this.
<?php View::newInstance()->_exportVariableToView('latestItems', klass24_pt_random_items()); ?>
<?php if( osc_count_latest_items() > 0) { ?>
<div class="block">
<div class="wrap">
<?php $c = 1; ?>
<?php while( osc_has_latest_items() ) { ?>
<?php if(osc_is_this_category('skip_latest', osc_item_category_id())) { ?>
<?php continue; ?>
<?php } ?>
<?php klass24_pt_draw_item($c, 'gallery'); ?>
<?php $c++; ?>
<?php } ?>
I set in administration to display in latest listings 30 listings and that value comes in function:
osc_count_latest_items() with value = 30
I build a plugin to skip listings from selected categorie to be displayed in latest listings section...
The problem is if i have for example 4 listings in a selected category to be displayed in latest listings, im entring 4 times inside the below code and the continue statement send me again for the "while":
<?php if(osc_is_this_category('skip_latest', osc_item_category_id())) { ?>
<?php continue; ?>
<?php } ?>
The final result, and my issue is instead have 30 listings in latest listings i only have 26, because i enter 4 times in thw loop with the statement inside...
So the question is, how can i solve this????
Best Regards
on :September 21, 2019, 5:05 pm #26
Hi! Why you don't use osc_query_items function?
And include only categories that you want to display.
<?php
osc_query_item(array(
"category" => "id_1,id_2"
));
if( osc_count_custom_items() == 0) { ?>
<?php while ( osc_has_custom_items() ) { ?>
//items
<?php } ?>
<?php } ?>
on :September 21, 2019, 5:25 pm #27
I'll never use that function, i will try to know a little bit more about...
Thanks for the tip
Best Regards
on :September 21, 2019, 5:27 pm #28
Remember that you need to include the categories from which you want to display items, not excluded categories.