Favorites Plug-in: Count listings

6 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 25, 2011   (RSS)

By gversion - June 28, 2011

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

Re: [gversion] Favorites Plug-in: Count listings

By robin - June 29, 2011

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.


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


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Favorites Plug-in: Count listings

By gversion - June 29, 2011

Hi Robin,

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

Thanks again for all your help.

Regards,
Greg

Re: [gversion] Favorites Plug-in: Count listings

By gversion - July 22, 2011

Hi Robin,

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

<?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

Re: [gversion] Favorites Plug-in: Count listings

By robin - July 25, 2011

Hey Greg,

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

Robin
Robin
Programmer
interactivetools.com