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: [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

Re: [Rusty] more fav lists

By Jason - March 3, 2011

Hi,

What you need to do is to first get all the favorite records for that user and that table. You can then use those favorite records to get the corresponding records in the items table. You can also manually set the orderBy option with whatever is in the URL.

Try this:

$favoritesQuery = "SELECT * FROM `{$TABLE_PREFIX}_website_favorites` WHERE createdByUserNum = '".intval($CURRENT_USER['num'])."' AND tableName = 'items'";
$favoritesRecords = mysql_query_fetch_all_assoc($favoritesQuery);

$favoritesRecordsNum = join( ",", array_pluck($favoritesRecords,'recordNum' ) );

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


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/