Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Favorites Plug-in: Count listings

 

 


gversion
User

Jun 28, 2011, 1:38 PM

Post #1 of 6 (1770 views)
Shortcut
Favorites Plug-in: Count listings Can't Post

Hello,

I've just bought the Favorites Plug-in and I'd like to display the total number of Favorites that a user has.

I'd be really grateful if someone could someone please tell me how to achieve this.

Thanks,
Greg


robin
User / Moderator


Jun 29, 2011, 9:15 AM

Post #2 of 6 (1755 views)
Shortcut
Re: [gversion] Favorites Plug-in: Count listings [In reply to] Can't Post

Hey Greg,

The data for Website Favorites is stored in a hidden table called "_website_favorites". You can see it in the Section Editor. I've included an example below of displaying how many favourites a user has. In this case it's user with num of 1.



Code
  // load records 
list($_website_favoritesRecords, $_website_favoritesMetaData) = getRecords(array(
'tableName' => '_website_favorites',
'where' => "createdByUserNum='1'"
));
echo $_website_favoritesMetaData['totalRecords'];


Hope that helps,
Robin


gversion
User

Jun 29, 2011, 10:40 AM

Post #3 of 6 (1753 views)
Shortcut
Re: [robin] Favorites Plug-in: Count listings [In reply to] Can't Post

Hi Robin,

Many thanks for the help. I seem to have got this to work! :)

Thanks again for all your help.

Regards,
Greg


gversion
User

Jul 22, 2011, 12:36 PM

Post #4 of 6 (1697 views)
Shortcut
Re: [gversion] Favorites Plug-in: Count listings [In reply to] Can't Post

Hi Robin,

Could you please tell me how to update the code you provided so that it displays the total number of listings for the currently logged in user?

The example you provided was just for a user with UserNum='1'

Thank you,
Greg


gversion
User

Jul 22, 2011, 12:49 PM

Post #5 of 6 (1694 views)
Shortcut
Re: [gversion] Favorites Plug-in: Count listings [In reply to] Can't Post

Hi Robin,

I seem to have got this working by changing the code to be as follows:


Code
<?php  
// load favorites records
list($_website_favoritesRecords, $_website_favoritesMetaData) = getRecords(array(
'tableName' => '_website_favorites',
'where' => "createdByUserNum= '".mysql_escape($CURRENT_USER['num'])."'"
));

?>



Unsure if that's the way you would have suggested, but it appears to work! :)

Thanks,
Greg


robin
User / Moderator


Jul 25, 2011, 8:42 AM

Post #6 of 6 (1445 views)
Shortcut
Re: [gversion] Favorites Plug-in: Count listings [In reply to] Can't Post

Hey Greg,

That looks good to me. $CURRENT_USER['num'] is exactly what I would use.

Robin