Support Forums - Classified Ads Script Osclass
Osclass plugin support => Favorite Items Plugin => Topic started by: BabyDunk 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?
<?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
-
@BabyDunk
There is no such function yet, will add it in next version.
Easiest way is to do:
$c = 0;
foreach( fi_list_items() as $i ) {
$c++;
}
echo $c;
I did not test the code so not sure if it works good.
-
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
<?php function fi_count_list() {
$c = 0;
foreach(fi_list_items() as $i ) {
$c++;
}
echo $i;
}
?>
then this
<?php if( fi_count_list() > 0 ) { ?>
<?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 } ?>
-
@BabyDunk
You want to echo variable $c, that is counter.
-
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 :-/
-
@BabyDunk
Ok soon I will add counting function to plugin.
-
Thank you Frosticek :D