We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

hook: publish_form_new_tabs

Development and Programming

wineknow's avatar
wineknow
15 posts
17 years ago
wineknow's avatar wineknow

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

       
wineknow's avatar
wineknow
15 posts
17 years ago
wineknow's avatar wineknow

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

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

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

       
wineknow's avatar
wineknow
15 posts
17 years ago
wineknow's avatar wineknow

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
       
Jamie Poitra's avatar
Jamie Poitra
409 posts
17 years ago
Jamie Poitra's avatar Jamie Poitra

AH,

I see now. Interesting. I’m going to have to revisit this when I have a moment.

Jamie

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.