I have created new tabs in the edit/publish control panel for two of my extensions (CoolLocation and CoolCommerce). IF there is ONLY 1 new tab to be created everything works fine. But, when there is multiple tabs (my tabs or other extensions) only the one with the highest priority number is displayed. Eg. if I put CoolLocation at priority 9 and CoolCommerce at priorty 10, only CoolCommerce appears.
It appears that publish_tabs is being passed by value and not by reference.
function my_new_tab($publish_tabs, $weblog_id, $entry_id) {
$publish_tabs['coollocation'] = "CoolLocation";
return $publish_tabs;
}
? -kevin
ok, to get around this, here is what I did.
in the publish_form_new_tabs hook:
[code]if ( ($EXT->last_call) && (is_array($EXT->last_call)) ) {
$publish_tabs = $EXT->last_call;
}
-- then my add to publish_tab[/code]
in the publish_form_new_tabs_block hook: <pre><code>if ( ($EXT->last_call) && (is_string($EXT->last_call)) ) { $myout = $EXT->last_call; } else { $myout = “”; }
$myout .= my html for my tab block[/code]
this seem to fix the issue and not break anything so far. -kevin
wineknow,
(hehe, just got the name after typing it out).
OK, so you got around this by hacking the original files right? Thats kind of defeating the purpose of using extensions as you now have to remember that and make sure you make the change every time you update EE. I’m not sure why you would have issues with multiple tabs. It sounds like the tab array being sent to the last extension call is always the old one pre the previous extension. This obviously isn’t ideal if that is indeed what is happening.
Am I reading you correctly?
Jamie
nope to hacking original files. obviously that would defeat the purpose. my solution works around something that did not work as expected. (if you have two extensions that add new tabs only one will show up -unless you do the gymnastics that I mentioned above). - my code goes into the extension itself:
function geocode_tab($publish_tabs, $weblog_id, $entry_id) {
global $EXT;
//
// an oddity in EE where if you have multiple hooks for the control panel
// tab, you need to do the following...
//
if ( ($EXT->last_call) && (is_array($EXT->last_call)) ) {
$publish_tabs = $EXT->last_call;
}
//
// now determine if we need to add this tab
//
if (in_array($weblog_id, $this->weblog_list))
$publish_tabs['coollocation'] = "CoolLocation";
return $publish_tabs;
}
wineknow, (hehe, just got the name after typing it out). OK, so you got around this by hacking the original files right? Thats kind of defeating the purpose of using extensions as you now have to remember that and make sure you make the change every time you update EE. I’m not sure why you would have issues with multiple tabs. It sounds like the tab array being sent to the last extension call is always the old one pre the previous extension. This obviously isn’t ideal if that is indeed what is happening. Am I reading you correctly? Jamie
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.