PDA

View Full Version : Portlets with jQuery - saving their position


ct2k7
07-21-2009, 05:29 PM
Hello,

I am attempting to build a portal, located here:

http://thinkteen.co.uk/portal

Currently, the portlets are hard coded into the portal page as can bee seen via the source.

What I need to be able to do is to:


User able to move portlets (achieved)
New portlet position to be saved


So, basically, I have though about making an AJAX request to POST to a PHP file on the server which saves the new position in the MySQL backend.

IE:

On widget drop ajax POST to /widget.php with position info(maybe container name + item index) ('leftBar',3), maybe account # that is specific to user, as well as the identifier for the module -->

$.post("widget.php", { module: "myInfoModule", container: 'leftBar'},"json");

Would that be correct?

in widget.php, it writes to the database the new position of the widget/portlet.

Now here's the other thing I need to achieve; to be able to read the modules and position from database, and place them in their respective places.

I am not entirely sure what to do here.

Thanks :)

jasondavis
07-22-2009, 01:46 AM
I'll give you a tip how I do it, I have 2 columns

in the DB I store the portlet positions like this 1-1|1-2|1-3|1-4|2-5|2-6 for each user.

Then on my 2 columns I run some code to detect which numbers are in that row, I then have each portlet in it's own file and the file is named by the number it represents, I then just include the files in the order that they are supposed to show up in