1. Osclass Forum
  2. Other
  3. Question about continue statement

Question about continue statement

Started by João Carrolo, September 21, 2019, 4:44 pm

  • 1

João Carrolo

Question about continue statement

on :September 21, 2019, 4:44 pm #25

I have a question regarding programming using "continue" statement


The code is  this.

Code: [Select]
​            <?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


calinbehtuk

Re: Question about continue statement

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.


Code: [Select]
​<?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 } ?>



  • << Last edit: September 21, 2019, 5:07 pm by calinbehtuk >>
  • Quote

João Carrolo

Re: Question about continue statement

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

calinbehtuk

Re: Question about continue statement

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.

  • 1
Subscribe
X

Subscribe!

Subscribe to get the latest listings, updates and special offers delivered directly in your inbox.