*

BabyDunk

  • ****
  • 161 posts
[Help] how to count fi_list_items ?
« on: August 15, 2016, 04:43:46 PM »
Hello

i need some help, i am trying to display a message when no listings have been added to the favorite list. i am having trouble figuring out how to count the favorite items in list.


this doesnt work but could you give any pointers?
Code: [Select]
                          <?php if( osc_count_items(fi_list_items()) > 0) { ?>
                                      <?php if(function_exists('fi_list_items')) { echo fi_list_items(); } ?>
                                                                                                                           
                           <?php } else { ?>
                             <div class="favlistmess">
                             <?php _e('You have not loved any listings yet, you do know love makes the world go round?''patricia' ) ; ?>
                            </div>
                           <?php ?>




Thanks
Chris
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: [Help] how to count fi_list_items ?
« Reply #1 on: August 16, 2016, 02:07:40 PM »
@BabyDunk
There is no such function yet, will add it in next version.
Easiest way is to do:

Code: [Select]
$c = 0;
foreach( fi_list_items() as $i ) {
  $c++;
}

echo $c;

I did not test the code so not sure if it works good.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: [Help] how to count fi_list_items ?
« Reply #2 on: August 17, 2016, 07:34:15 AM »
Hi

thanks for the reply but it didn't work. i have been searching for hrs on different forums and it seems that this is the right syntax but its just not counting

when i  echo $c  i get a 0 which i understand but when i echo $i i get nothing :-/

this is what i have done just incase its something i have done

i make a function
Code: [Select]
<?php function fi_count_list() {
                        
$c 0;
                    foreach(
fi_list_items() as $i ) {
                        
$c++;
                    }
                    echo 
$i;  
             }
?>


then this
Code: [Select]
<?php if( fi_count_list() > ) { ?>
                                      <?php if(function_exists('fi_list_items')) fi_list_items(); ?>
                                                                                                                           
                           <?php } else { ?>
                            <div class="favlistmess2">
                             <span><?php _e('You have not loved any listings yet, you do know love makes the world go round?''patricia' ) ; ?><i class="fa fa-smile-o"></i></span>
                            </div>
                     <?php ?>

I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: [Help] how to count fi_list_items ?
« Reply #3 on: August 17, 2016, 10:24:26 AM »
@BabyDunk
You want to echo variable $c, that is counter.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: [Help] how to count fi_list_items ?
« Reply #4 on: August 17, 2016, 10:57:08 AM »
aww right, i was getting that mixed up from reading posts on other forums, thanks for clarifying that. i have done both anyway, when i put variable $c  i get 0 no matter how many listings is in the favorites list :-/

I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D

*

MB Themes

Re: [Help] how to count fi_list_items ?
« Reply #5 on: August 17, 2016, 12:36:24 PM »
@BabyDunk
Ok soon I will add counting function to plugin.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

BabyDunk

  • ****
  • 161 posts
Re: [Help] how to count fi_list_items ?
« Reply #6 on: August 17, 2016, 01:16:27 PM »
Thank you Frosticek :D
I Am A Noob But I Am Here To Learn.
Please be patient ;) ;D