Reorder Tabs

This topic contains 10 replies, has 3 voices, and was last updated by  Simone 9 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #43097

    Paola Bueso
    Free User
    Post count: 40

    Hi,
    There are 3 things I would like to do, but can’t seem to get them right yet, I’m very much new at this. I’ve attached an image of the details section of the site for reference.

    1. I’d like to eliminate the ‘Profile’ section.
    2. I’d like to move the ‘Basic Information’ tab, so that it sits where the ‘Profile’ tab used to be.
    3. I’d like for the content in the ‘Basic Information’ tab to be visible as soon as you open the page.

    I tried following the directions seen here: https://wpgeodirectory.com/support/topic/exclude-selected-tabs-from-detail-page-if-empty/#post-7305 in order to reorder the tabs. But the field set “Basic Information”, which I set as a tab on the details page, didn’t include an HTML variable field, so I just used “basic_information” to represent the tab. That might have to do with why it isn’t working. Here is what I ultimately added to my functions.php file on the child theme:

    
    
    add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ;
    
    function geodir_detail_page_tab_list_extend($tab_array)
    {
     // here u can modify this array, u can create a completely new one too.
         if(isset($tab_array['basic_information'])){
             $new_tab_array['basic_information'] = $tab_array['basic_information']; // set in new array
    		 unset($tab_array['basic_information']);//unset in old one
    	 }
        
         if(isset($tab_array['post_profile'])){
             $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array
    		 unset($tab_array['post_profile']);//unset in old one
    	 }
    
         if(isset($tab_array['post_map'])){
             $new_tab_array['post_map'] = $tab_array['post_map'];// set in new array
    		 unset($tab_array['post_map']);//unset in old one
    	 }
    
        if(isset($tab_array['special_offers'])){
             $new_tab_array['special_offers'] = $tab_array['special_offers'];// set in new array
    		 unset($tab_array['special_offers']);//unset in old one
    	}
    
         if(isset($tab_array['post_info'])){
             $new_tab_array['post_info'] = $tab_array['post_info'];// set in new array
    		 unset($tab_array['post_info']);//unset in old one
    	 }
    
        if(isset($tab_array['post_images'])){
             $new_tab_array['post_images'] = $tab_array['post_images'];// set in new array
    		 unset($tab_array['post_images']);//unset in old one
    	}
    
        if(isset($tab_array['post_video'])){
             $new_tab_array['post_video'] = $tab_array['post_video'];// set in new array
    		 unset($tab_array['post_video']);//unset in old one
    	}
    
         if(isset($tab_array['special_offers'])){
             $new_tab_array['special_offers'] = $tab_array['special_offers'];// set in new array
    		 unset($tab_array['special_offers']);//unset in old one
    	 }
    
         if(isset($tab_array['reviews'])){
             $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array
    		 unset($tab_array['reviews']);//unset in old one
    	 }
    
        if(isset($tab_array['related_listing'])){
            $new_tab_array['related_listing'] = $tab_array['related_listing'];// set in new array
    		unset($tab_array['related_listing']);//unset in old one
    	}
    	
    	// now we set any remaining tabs that have not been assigned an order
    	foreach($tab_array as $key=>$tab){
    	$new_tab_array[$key]=$tab;
    	}
    
        return $new_tab_array ;
    }

    Thank you in advance for your help!
    Paola

    #43126

    Simone
    Expired Member
    Post count: 3515

    Hello Paola,
    how come the basic information is without html variable name? Is it a fieldset? However, the default tab must be set it as active with

    
    
    $new_tab_array['basic_information']['is_active_tab']='1';
    
    

    place it before

    
    
    unset($tab_array['basic_information']);//unset in old one
    

    and you should remove the Profile from the active tabs

    
    
    $new_tab_array['post_profile']['is_active_tab']='';
    

    place it before

    
    
    unset($tab_array['post_profile']);//unset in old one
    
    #43128

    Paola Bueso
    Free User
    Post count: 40

    Thank you so much for the response! Yes, it is a fieldset.

    #43129

    Paola Bueso
    Free User
    Post count: 40

    This is what I’ve put in the child theme’s function.php now:

    
    
    add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ;
    
    function geodir_detail_page_tab_list_extend($tab_array)
    {
     // here u can modify this array, u can create a completely new one too.
         if(isset($tab_array['basic_information'])){
             $new_tab_array['basic_information'] = $tab_array['basic_information']; // set in new array
                 $new_tab_array['basic_information']['is_active_tab']='1';
    		 unset($tab_array['basic_information']);//unset in old one
    	 }
        
         if(isset($tab_array['post_profile'])){
             $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array
                 $new_tab_array['post_profile']['is_active_tab']='';
    		 unset($tab_array['post_profile']);//unset in old one
    	 }
    
         if(isset($tab_array['post_map'])){
             $new_tab_array['post_map'] = $tab_array['post_map'];// set in new array
    		 unset($tab_array['post_map']);//unset in old one
    	 }
    
        if(isset($tab_array['special_offers'])){
             $new_tab_array['special_offers'] = $tab_array['special_offers'];// set in new array
    		 unset($tab_array['special_offers']);//unset in old one
    	}
    
         if(isset($tab_array['post_info'])){
             $new_tab_array['post_info'] = $tab_array['post_info'];// set in new array
    		 unset($tab_array['post_info']);//unset in old one
    	 }
    
        if(isset($tab_array['post_images'])){
             $new_tab_array['post_images'] = $tab_array['post_images'];// set in new array
    		 unset($tab_array['post_images']);//unset in old one
    	}
    
        if(isset($tab_array['post_video'])){
             $new_tab_array['post_video'] = $tab_array['post_video'];// set in new array
    		 unset($tab_array['post_video']);//unset in old one
    	}
    
         if(isset($tab_array['special_offers'])){
             $new_tab_array['special_offers'] = $tab_array['special_offers'];// set in new array
    		 unset($tab_array['special_offers']);//unset in old one
    	 }
    
         if(isset($tab_array['reviews'])){
             $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array
    		 unset($tab_array['reviews']);//unset in old one
    	 }
    
        if(isset($tab_array['related_listing'])){
            $new_tab_array['related_listing'] = $tab_array['related_listing'];// set in new array
    		unset($tab_array['related_listing']);//unset in old one
    	}
    	
    	// now we set any remaining tabs that have not been assigned an order
    	foreach($tab_array as $key=>$tab){
    	$new_tab_array[$key]=$tab;
    	}
    
        return $new_tab_array ;
    }

    It’s not quite right yet. I’ve attached an image of what you can see now as soon as you open the page. Maybe the problem has to do with the fact that the “Basic Information” tab is a fieldset. I don’t know what I should use as the HTML variable name for this tab, like, instead of using the name “basic_information”. I hope you can point me in the right direction. Thank you once again for your help!
    Paola

    #43131

    Simone
    Expired Member
    Post count: 3515

    Ciao Paola, this is a not-so-common issue (the handling of a tab without a html variable name) so I will ask to Stiofan and get back at you as soon as I will know something.

    #43132

    Paola Bueso
    Free User
    Post count: 40

    Thank you so much Simone! I really appreciate it.

    #43133

    Simone
    Expired Member
    Post count: 3515

    OK wait, add the following function in your functions.php file

    
    
    function geodir_detail_page_tab_list_extend_profile($tab_array)
    {
    print_r($tab_array);
    }

    This will output the tab index, so you can see what’s the name of the fieldset for the basic information, once you know it you can use the previously posted function, changing the name of the basic_information you used before

    #43136

    Paola Bueso
    Free User
    Post count: 40

    I’ve added the code to the functions.php and saved it. I don’t really know where to look for the tab index output tho. I’ve attached an image for reference. Nothing has really changed since saving the code. Again, thank you so much for the help.

    #43170

    Paolo
    Site Admin
    Post count: 31211

    Hi Paola,

    my bad I gave Simone an incomplete information.

    You need to call that function via a filter or it will not appear anywhere.

    This:

    
    
    add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend_profile') ;
    function geodir_detail_page_tab_list_extend_profile($tab_array)
    {
    print_r($tab_array);
    }

    Will print the array with all info instead of the tabs. By doing so you can find the tab index for the tab with fieldset. At this point remove the above function and use the correct tab index for your function to re-order tabs.

    Let us know if this works for you.

    Thanks for your patience!

    #43203

    Paola Bueso
    Free User
    Post count: 40

    Brilliant! Thank you so much Paolo & Simone for all your help! You’ve been outstanding! The plugin is absolutely amazing and your support has been absolutely amazing! I’m off to purchase the membership now. Grazie mille! 😀

    #43220

    Simone
    Expired Member
    Post count: 3515

    You’re very welcome Paola, enjoy GD! 🙂

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount