Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Re-Order Tabs In Admin: Products: Edit-View Rate Topic   - - - - -

 
  • a3lanjo
  • Member
  • Trial users
  • Join Date: 14-Sep 20
  • 35 posts

Posted 12 December 2020 - 02:53 AM #1

Hello All, 

 

I would like change positions for Tabs In Admin: Products: Edit-View

 

For Ex: I want move some tabs to the first and some to the end.

 

Kindly check attached

 

What the best way to do that ?

 

Thank you all



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12071 posts

Posted 12 December 2020 - 09:51 PM #2

I believe on the admin side you would need a small chunk of custom code to reorder the navigation tabs data that is generated.  I would use a 'post' controller like app/addons/my_changes/controllers/backend/products.post.php containing something similar to (not tested, just an idea):

if( !defined('BOOTSTRAP') ) die('Access denied');
 
use Tygh\Registry;
 
if( $_SERVER['REQUEST_METHOD'] == 'GET' && ($nav_tabs = Registry::get('navigation.tabs')) ) {
  $my_tab_order = array('general', 'options', 'shippings', 'qty_discounts', 'product_tabs', 'seo'); // all the rest will be copied over in their original order
  $new_tabs = array();
  foreach($my_tab_order as $tab_id) {
    if( isset($nav_tabs[$tab_id]) ) {
      $new_tabs = $nav_tabs[$tab_id];
      unset($nav_tabs[$tab_id]);
    }
    // Unspecified tabs are left in $nav_tabs;
  }
  if( !empty($nav_tabs) )
    $new_tabs = array_merge($new_tabs, $nav_tabs);
  Registry::set('navigation.tabs', $new_tabs);
}
return array(CONTROLLER_STATUS_OK);

 

This should result with a tab order of general, options, shippings, qty_discounts, product_tabs, seo, files, subscribers, addons, features,buy_together, attachments and blocks.  Followed by any addons that may add to your product tabs.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • a3lanjo
  • Member
  • Trial users
  • Join Date: 14-Sep 20
  • 35 posts

Posted 13 December 2020 - 11:43 PM #3

I believe on the admin side you would need a small chunk of custom code to reorder the navigation tabs data that is generated.  I would use a 'post' controller like app/addons/my_changes/controllers/backend/products.post.php containing something similar to (not tested, just an idea):

if( !defined('BOOTSTRAP') ) die('Access denied');
 
use Tygh\Registry;
 
if( $_SERVER['REQUEST_METHOD'] == 'GET' && ($nav_tabs = Registry::get('navigation.tabs')) ) {
  $my_tab_order = array('general', 'options', 'shippings', 'qty_discounts', 'product_tabs', 'seo'); // all the rest will be copied over in their original order
  $new_tabs = array();
  foreach($my_tab_order as $tab_id) {
    if( isset($nav_tabs[$tab_id]) ) {
      $new_tabs = $nav_tabs[$tab_id];
      unset($nav_tabs[$tab_id]);
    }
    // Unspecified tabs are left in $nav_tabs;
  }
  if( !empty($nav_tabs) )
    $new_tabs = array_merge($new_tabs, $nav_tabs);
  Registry::set('navigation.tabs', $new_tabs);
}
return array(CONTROLLER_STATUS_OK);

This should result with a tab order of general, options, shippings, qty_discounts, product_tabs, seo, files, subscribers, addons, features,buy_together, attachments and blocks.  Followed by any addons that may add to your product tabs.

 

Thank you so much 
 
 
I tried with same code, but something issue or missing i dont know, Check attached please
 
 


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12071 posts

Posted 14 December 2020 - 12:00 AM #4

As I said, it's untested and it was free.  Suggest you have your developer review and either add some diagnostics or otherwise adjust.

You might need to 'get' the 'navigation' property versus 'navigation.tabs' and adjust and save the updated tabs instead.

I.e.

if( !defined('BOOTSTRAP') ) die('Access denied');
 
use Tygh\Registry;
 
if( $_SERVER['REQUEST_METHOD'] == 'GET' && ($nav = Registry::get('navigation')) ) {
  $nav_tabs = empty($nav['tabs']) ? [] : $nav['tabs'];
  $my_tab_order = array('general', 'options', 'shippings', 'qty_discounts', 'product_tabs', 'seo'); // all the rest will be copied over in their original order
  $new_tabs = array();
  foreach($my_tab_order as $tab_id) {
    if( isset($nav_tabs[$tab_id]) ) {
      $new_tabs = $nav_tabs[$tab_id];
      unset($nav_tabs[$tab_id]);
    }
    // Unspecified tabs are left in $nav_tabs;
  }
  if( !empty($nav_tabs) )
    $new_tabs = array_merge($new_tabs, $nav_tabs);
  $nav['tabs'] = $new_tabs;
  Registry::set('navigation', $nav);
}
return array(CONTROLLER_STATUS_OK);

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • a3lanjo
  • Member
  • Trial users
  • Join Date: 14-Sep 20
  • 35 posts

Posted 14 December 2020 - 11:50 PM #5

 

As I said, it's untested and it was free.  Suggest you have your developer review and either add some diagnostics or otherwise adjust.

You might need to 'get' the 'navigation' property versus 'navigation.tabs' and adjust and save the updated tabs instead.

I.e.

if( !defined('BOOTSTRAP') ) die('Access denied');
 
use Tygh\Registry;
 
if( $_SERVER['REQUEST_METHOD'] == 'GET' && ($nav = Registry::get('navigation')) ) {
  $nav_tabs = empty($nav['tabs']) ? [] : $nav['tabs'];
  $my_tab_order = array('general', 'options', 'shippings', 'qty_discounts', 'product_tabs', 'seo'); // all the rest will be copied over in their original order
  $new_tabs = array();
  foreach($my_tab_order as $tab_id) {
    if( isset($nav_tabs[$tab_id]) ) {
      $new_tabs = $nav_tabs[$tab_id];
      unset($nav_tabs[$tab_id]);
    }
    // Unspecified tabs are left in $nav_tabs;
  }
  if( !empty($nav_tabs) )
    $new_tabs = array_merge($new_tabs, $nav_tabs);
  $nav['tabs'] = $new_tabs;
  Registry::set('navigation', $nav);
}
return array(CONTROLLER_STATUS_OK);

Thank you, I modified the code and it working very well with me :

<?php
if( !defined('BOOTSTRAP') ) die('Access denied');
 
use Tygh\Registry;
 
if( $_SERVER['REQUEST_METHOD'] == 'GET' && ($nav_tabs = Registry::get('navigation.tabs')) ) {
  $my_tab_order = array('detailed', 'options', 'features', 'package_info', 'addons', 'product_tabs'); // all the rest will be copied over in their original order
  $new_tabs = array();
  foreach($my_tab_order as $tab_id) {
    if( isset($nav_tabs[$tab_id]) ) {
      $new_tabs[$tab_id] = $nav_tabs[$tab_id];
      if($tab_id == 'addons') {
	      $new_tabs[$tab_id]['title'] = 'Important Options';
      }
      unset($nav_tabs[$tab_id]);
    }
    // Unspecified tabs are left in $nav_tabs;
  }
  if( !empty($nav_tabs) )
    $new_tabs = array_merge($new_tabs, $nav_tabs);
  Registry::set('navigation.tabs', $new_tabs);
}
return array(CONTROLLER_STATUS_OK);

?>