What is Posh ?
| Download
| Documentation
| Forum
| Widgets
| Plug-ins
| Translator
| Contribute
| Blog
You are not logged in.
Hello :-)
I am using portaneo Version 2.1.2 (please - I have to stay with this version) for a research project involving widgets run simultaneously.
For a further use case I have to implement the following functionality:
There are a tab "X" and a created tab "RX" (using a modification of the function $p.app.pages.newEmpty inside ajax.js).
Clicking on some link I need now to clone certain Widgets inside a "static" (stored) tab "X" into the new tab "RX", and reload each new cloned widget with a given url. I tried to modify the function $p.app.widgets.createAll and the function $p.app.widgets.create(), in order to get the widtegs into the new temporary tab "RX", but I had no success and I am still struggling through the code - anybody could help me?
Thank you very very much
good bye
Offline
Hello,
You can inspire from the process that moves a widget from a tab to another ($p.app.widgets.changeTab in ajax.js), or the one that create a widget in another tab ($p.app.widgets.insertInTab)
Best -
Offline
Hello Eric
thank you very much for your advice.
Even if I try to get inspired by using $p.app.widgets.insertInTab ... it does not display any copy of the widgets.
As long as I get acquainted with the ajax code, it seems that a widget (called module in portaneo) be first of all something in xml, written down to a file and instantiated to an iframe whenewer the user needs it.
I consider having on a first tab my widgets already instanciated and would like to
1. generate a new tab (with a new tab id)
2. clone each widget inside the new tab
3. use each widget inside the new tab
I had success in creating an elegant new tab (with an icon :-) ! This was fine.
A pity that on application reload the icon is not redisplayed... :-(
Furthermore I try and try to clone widgets (inside modules) but do not see any widget inside my fresh new tab...
What am I doing wrong? I do have to try&error quite a number of times...
The code snippet I use is the following (modules is a vector of portaneo modules which belong to the first tab):
for(var i=0;i<modules.length;i++)
{
var widget=modules[i];
pclass.app.widgets.insertInTab(newtab_id,widget.id,widget.vars);
pclass.app.widgets.placeIn(widget,widget.pos,widget.col,false,newtab_id);
widget.create();
}
Even if I omit placeIn() I do not see any widget... and do not see any errors (e.g. in the javascript firebug console)
A further question is whether the new tab and the cloned widget are also registered in the portaneo database...
Thank you again
Bye
Fabio
Offline
Unfortunately the code in ajax.js is not too robust.
After having fixed a particularity in the function set()
if (tab[v_extra].module.length > 0 ) // FRI
{
if (tab[v_extra].module[l_id].blocked)
return;
}
else return; //FRI
instead of
if (tab[v_extra].module[l_id].blocked)
return;
--- the problem here is that module is supposed to have some children, and if not return, but if there are no children, any further access to some sub structure are invane and cause an error and exec stop. --
After fixing this, I can see the widgets in the new tab BUT: if I switch back to the originary tab, the widgets have disappeared from there.
swiching back and fort between tabs let the widgets disappear definitively from any tab. Maybe I still do not see some needed function to make widgets persistent ... in the new tab ... and in the originary tab.
Thank you again
Goodbye
Fabio
Offline
Hi
probably Iwill have to check all code, but I found the reason why cloned widgets were not reproduced:
In function insertInTab() there is a bug calling in $p.ajax.call(posh["scr_addmodule_intab"] ...) with the tab sequence number instead of the v_proof number (the fresh new profile.id of the newly created tab).
This explains the malfunction of cloning and not finding widgets after reload: Each time a widget is created, the false module.profile_id is given.
After reload, init() cannot find the tab using the wrong module.profile_id.
This alone still doesn't fix all other small particularities (icon not stored, positions to be corrected,...) but is a start.
Bye
Fabio
Offline
Hi Fabio,
It seems that even if you met some difficulties, your project is on the right way.
"Icon is not stored" > The tab icon or the widget icon ? Did you look at the /portal/scr_createportal.php script ? tabs icons are stored in the icon field of profile table
"positions to be corrected" > The tabs position ? tabs positions are stored in "seq" field of profile table.
We will look the bug you mentioned.
Offline
Hi Eric
thank you for your advice. It is the TAB icon and obviously I meant /portal/scr_createportal.php. Yes, the icon is stored in the table under the "icon" column It is read in (by /portal/scr_createportal.php) as parameter "i", and I use to create a new tab the following command:
tab.push(new $p.app.tabs.object(lastTabNumber, //id - uniq id of the tab
refine_info[3], //label
1, //type - type of the tab (personalized page, frame, ...)
"", //function called when tab is opened
0, //lock (boolean) - is the tab locked ?
lastTabSeq, //seq - tab sequence (gives order information)
0, //editable (boolean) - is the tab editable
1, //movable (boolean) - is the tab movable
"/rodinposh/u/images/color_wheel.png", //icon - icon displayed in the tab
1, //loadstart (boolean) - is the tab loaded on application startup (application for personalized pages)
0, //status - Page durch admin eingeführt
"", //param
0, //pageId - if pageId 1, page linked to 'pages' in the database.
1));
The "color_weehl" icon has to be passed by newEmpty() to the php script /portal/scr_createportal.php as "i" Parameter under "variables". This is not the case in the code. I adjusted the code and it works. I have now some strange effects - I can store tab and modules but if I repete the operation twice one after another the platform does not show the modules (initialisation problem... sth must still be missing)
The tab-seq / tab-id problem seems to be solved. There is a tab seq the tab index of the instanciated tabs in the browser and a tab id (in the DB), in the code there was a bad use of the db tab id, (see above), so the modules could not be rendered out of the information in the db. I fixed that and it works now.
Well, I have often to debug = reverse engineer the code to understand it, this takes 3 times the planned time but at the end you unterstand a bit more of the logics ;-))
Bye
Fabio
Offline
Hi Eric
a small question:
Why in the function openCreatedTab()
compares the following instruction? v_prof = tab.length;
With this instruction the v_poof (the tab db id) is set to tab.length (number of tabs in the instanciated portaneo code inside the Javascipt DOM), hence here I lost the tab db id (profile_id) ... ?
Thanks
Bye
Fabio
Offline
3rd - post
Now I realize the difficulties/challengies developing the portaneo code.
You have to fire the same (or nearly the same) function
1) over php scripts in order to make change persistent (DB)
2) in the Javascript DOM - in order to visualize it in the browser
Hence, here the challenge is to write and to revise code which do the same thing but on different layers (DB and Javascript).
For instance creating a new tab...
1) script scr_createportal.php
2) Javascript tab.push(new $p.app.tabs.object(...))
Here I found a new "difference": In case you want to create a new tab wich is not editable (7th arg in $p.app.tabs.object() function), this flag is ALWAYS read as editable during the initialization process, independentently of the value of the corresponding parameter ((7th arg in object() function) called in AJAX.
Offline
With this instruction the v_poof (the tab db id) is set to tab.length (number of tabs in the instanciated portaneo code inside the Javascipt DOM), hence here I lost the tab db id (profile_id) ... ?
Indeed... I do not know why. I will ask the Portaneo developers
Offline