How to save portlet positions

荒凉一梦 提交于 2019-12-12 03:45:16

问题


I will be using jQuery's functionality to create portlet widgets for my web application suit. I haven't started as of yet, but will do soon, so this is the planning

Now, currently, the page loads, and the widgets load into their default positions. A user can move them around, change their settings, whatever.

Now, my problem is that I want it such that the widget placement is saved for the user, not just per session, but as an account variable.

I am using PHP and MySQL for the level-base coding and I really have no clue where to start.

Please help me :)


回答1:


The general plan would be to do something like this

in jQuery

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', ...},
  function(data){
    // maybe update UI telling them it's saved? probably not
  }, "json");

in PHP /widget.php

read data and save information to mySQL in some schema like this

[user_id] [module_id]    [container]  [position]
1         'myInfoModule' 'leftBar'    3

Then, when you reload the dockable page you would read these values and put them in the order specified by the database.

Hope this gets you started



来源:https://stackoverflow.com/questions/1034360/how-to-save-portlet-positions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!