如何保存Portlet位置 [英] How to save portlet positions
问题描述
我将使用jQuery的功能为我的Web应用程序套装创建portlet小部件.我还没有开始,但是很快就会开始,所以这是计划
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.
我正在使用PHP和MySQL进行基于级别的编码,我真的不知道从哪里开始.
I am using PHP and MySQL for the level-base coding and I really have no clue where to start.
请帮助我:)
推荐答案
总体计划是做这样的事情
The general plan would be to do something like this
在jQuery中
小部件放置 ajax POST到/widget.php,带有位置信息(可能是容器名称+项目索引)('leftBar',3), 也许是用户专用的帐户#以及模块的标识符
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");
在PHP中/widget.php
in PHP /widget.php
以这样的模式读取数据并将信息保存到mySQL
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.
希望这可以帮助您入门
这篇关于如何保存Portlet位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!