more fav lists

8 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: March 3, 2011   (RSS)

By Maurice - October 3, 2010

Hi IT Team,

I want to use more fav lists can i do this and how do i set this up?

I want a personal list and a wish list and zo on.
or can a add multiple $tableOrTag and just display the right ones on 1 single page???

Greetz Maurice
-------------------------------------------

Dropmonkey.nl

Re: [Maurice] more fav lists

By Jason - October 4, 2010

Hi Maurice,

Yes, so long as you have a unique combination of createdByUserNum, tableOrTag, and recordNum, you can have as many lists are you want.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] more fav lists

By nkerschgens - October 5, 2010

Hi Jason,

I'm a coworker of maurice and i am working on this solution. Now i am able to add multiple favorites lists, that works fine!

Now i would like to show all the favorites (from all favoriteslist) in one foreach, is this possible.

Now i use this code to display each favorites list:
$currentUserNum = mysql_escape( @$CURRENT_USER['num'] );

// get favorite from LINKS record nums
$tableOrTagLinks = mysql_escape('links'); // update this with your table or tag name
$favoriteNumsQueryLinks = "SELECT recordNum FROM {$TABLE_PREFIX}_website_favorites WHERE tableOrTag = '$tableOrTagLinks' AND createdByUserNum = '$currentUserNum'";

$tableOrTagDocs = mysql_escape('docs'); // update this with your table or tag name
$favoriteNumsQueryDocs = "SELECT recordNum FROM {$TABLE_PREFIX}_website_favorites WHERE tableOrTag = '$tableOrTagDocs' AND createdByUserNum = '$currentUserNum'";

$tableOrTagFaq = mysql_escape('faq'); // update this with your table or tag name
$favoriteNumsQueryFaq = "SELECT recordNum FROM {$TABLE_PREFIX}_website_favorites WHERE tableOrTag = '$tableOrTagFaq' AND createdByUserNum = '$currentUserNum'";

$tableOrTagNews = mysql_escape('news'); // update this with your table or tag name
$favoriteNumsQueryNews = "SELECT recordNum FROM {$TABLE_PREFIX}_website_favorites WHERE tableOrTag = '$tableOrTagNews' AND createdByUserNum = '$currentUserNum'";

// load matching records
list($favoriteLinksRecords, $favoriteLinksMetaData) = getRecords(array(
'tableName' => 'links_dashboards', // update this with your table or tag name
'perPage' => '10',
'where' => " num IN ($favoriteNumsQueryLinks) ",
'loadCreatedBy' => false,
'allowSearch' => false,
));

list($favoriteDocsRecords, $favoriteDocsMetaData) = getRecords(array(
'tableName' => 'documenten_mem', // update this with your table or tag name
'perPage' => '10',
'where' => " num IN ($favoriteNumsQueryDocs) ",
'loadCreatedBy' => false,
'allowSearch' => false,
));

list($favoriteFaqRecords, $favoriteFaqMetaData) = getRecords(array(
'tableName' => 'faq', // update this with your table or tag name
'perPage' => '10',
'where' => " num IN ($favoriteNumsQueryFaq) ",
'loadCreatedBy' => false,
'allowSearch' => false,
));

list($favoriteNewsRecords, $favoriteNewsMetaData) = getRecords(array(
'tableName' => 'news', // update this with your table or tag name
'perPage' => '10',
'where' => " num IN ($favoriteNumsQueryNews) ",
'loadCreatedBy' => false,
'allowSearch' => false,
));


It will not surprise me if this can be done much easier...

Re: [nkerschgens] more fav lists

By Jason - October 5, 2010

Hi,

If you wanted to get all of the favorites records for a single user with one query, you could do this:

list($favoritesRecords,$favoritesMetaData)=getRecords(array(
'tableName' => '_website_favorites',
'allowSearch' => false,
'where' => "createdByUserNum=".intval($CURRENT_USER['num']),
));


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] more fav lists

By Rusty - February 27, 2011

Is there a way to filter results from a list page to ONLY show items currently in the Favorites table??

I know we can do:

<a href="?orderBy=title">
<a href="?orderBy=fieldname">

howevever this:

<a href="?createdByUserNum=<?php echo $CURRENT_USER['num'] ?>"><strong>View Favorites</strong></a>

just shows me records actually created by that user, not ones in their favorites.
Rusty

Re: [Rusty] more fav lists

By Jason - February 28, 2011

Hi Rusty,

I'm not sure I understand the problem you're encountering. Since a user can only create favorites for themselves, all the records in the website favorites table where createdByUserNum = $CURRENT_USER['num'] would be all of their favorites records.

Could you clarify exactly what results your getting and what results you were expecting?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] more fav lists

By Rusty - March 1, 2011

What I want to do sort and filter for a users particular favorites without having to hard code it in the head of the page.

eg:

// load matching records
list($favoriteRecords, $favoriteMetaData) = getRecords(array(
'tableName' => 'items', // update this with your table or tag name
// 'perPage' => '10',
'where' => " num IN ($favoriteNumsQuery) ",
'loadCreatedBy' => false,
'allowSearch' => false,
));


However I'm curious to see if we can do something similar to this:

<li>## <a href="?orderBy=title">Sort by Last Name /\</a> | <a href="?orderBy=title DESC">\/</a></li>
<li>## <a href="?orderBy=first_name">Sort by First Name /\</a> | <a href="?orderBy=first_name DESC">\/</a> </li>
<li>## <a href="?orderBy=email">Sort by Email /\</a> | <a href="?orderBy=email DESC">\/</a></li>


Right now I want to figure out how to sort a list page, showing items, and sort them so that the favorites come up first or last (DESC obviously)

From what I see if I do it like this:


?createdByUserNum=$CURRENT_USER['num'] is going to show just the documents (if any) created by that particular user, not necessarily showing me documents created by an admin, but favorited by the current user.

I hope this helps/makes sense.
Rusty