CodeIgniter Forums
Creating a "Saved Favorites" Function? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Creating a "Saved Favorites" Function? (/thread-51652.html)



Creating a "Saved Favorites" Function? - El Forum - 05-11-2012

[eluser]MatthewSchenker[/eluser]
Hello Everyone,
I've been building in CodeIgniter for the past few months, and like it more and more every day!

But I've run across a challenge I'm not sure how to deal with...

How would you create a "Saved Favorites" function in CodeIgniter? I'm talking about something where logged in users could click a button and the URL of the current page is saved to a list. Then on another page the user could see the list of "favorite" pages he/she has "saved" and click on an entry to jump to that page.

I'm sure others must have done this before me. Can anyone help me out?

Thank you,
Matthew

PS: I see that Solspace has exactly what I'm looking for in ExpressionEngine (http://www.solspace.com/software/detail/favorites/). Could this be brought into CodeIgniter?


Creating a "Saved Favorites" Function? - El Forum - 05-11-2012

[eluser]CroNiX[/eluser]
This would be very simple.

Just a table with id, user_id, url and page_title. SELECT url, page_title FROM table WHERE user_id = x. Then just make a list of links. Just use ajax or something to submit the entry.


Creating a "Saved Favorites" Function? - El Forum - 05-11-2012

[eluser]MatthewSchenker[/eluser]
Hi CroNIX,
Thanks for the quick response. Simple for you!

Well, OK, now that you describe it, I'm pretty sure how to do it.

Thank you again for your help. This community is one of the reasons I really enjoy CodeIgniter.

Matthew



Creating a "Saved Favorites" Function? - El Forum - 05-12-2012

[eluser]Rok Biderman[/eluser]
If there is something really simple you want to input(like an id), just make another text field in your users table called favorites, and serialize an array into it. When you need it just unserialize it and call array_push or array_diff to add and remove items.


Creating a "Saved Favorites" Function? - El Forum - 05-12-2012

[eluser]MatthewSchenker[/eluser]
Hello Coccodrillo,
Thanks for jumping in! I appreciate the input.

OK, I see the idea. Now I've got to test it.

In the meantime, if anyone has a working example of something like this, please share it.

Thanks again,
Matthew