Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Include loadtab.php in Core
#6
OK, here are the suggested changes:

plugin_functions.php / createSideMenu:
replace it with the following (compatible) code:
Code:
function createSideMenu($id, $txt, $action=null, $always=true){
  $current = false;
  if (isset($_GET['id']) && $_GET['id'] == $id && (!$action || isset($_GET[$action]))) {
    $current = true;
  }
  if ($always || $current) {
    echo '<li><a href="load.php?id='.$id.($action ? '&amp;'.$action : '').'" '.($current ? 'class="current"' : '').' >'.$txt.'</a></li>';
  }
}
$action will add an additional request parameter thus allowing multiple side menu items per plugin.
Setting $always to false will only show the menu item, if the page is active ($action should be non-empty)

plugin_functions.php / createNavTab:
Not compatible, but I doubt that anybody uses it.
Code:
function createNavTab($tabname, $id, $txt, $action=null) {
  global $plugin_info;
  $current = false;
  if (basename($_SERVER['PHP_SELF']) == 'load.php') {
    $plugin_id = @$_GET['id'];
    if ($plugin_info[$plugin_id]['page_type'] == $tabname) $current = true;
  }
  echo '<li><a href="load.php?id='.$id.($action ? '&amp;'.$action : '').'" '.($current ? 'class="current"' : '').' >'.$txt.'</a></li>';
}
$tabname is the name of the tab (e.g. "special"), the action for creating side menu items is the name of the tab plus "-sidebar" (e.g. "special-sidebar"), analog to the standard tabs (e.g. "pages-sidebar").
Other parameters like for createSideMenu.

To highlight the tab, add the following to the CSS (or rather add the selector to the already existing rule for highlighting):
Code:
<style type="text/css">
  #load .wrapper .nav li a.current {
    -moz-box-shadow: 2px -2px 2px rgba(0, 0, 0, 0.1);
    background: -moz-linear-gradient(center top , #FFFFFF 3%, #F6F6F6 100%) repeat scroll 0 0 transparent;
    color: #182227;
    font-weight: bold !important;
    text-shadow: 1px 1px 0 #FFFFFF;
  }
</style>

load.php:
Replace the <div id="sidebar"> ... </div> code with:
Code:
<div id="sidebar" >
    <?php
      $res = (@include('template/sidebar-'.$plugin_info[$plugin_id]['page_type'].'.php'));
      if (!$res) {
    ?>
      <ul class="snav">
        <?php exec_action($plugin_info[$plugin_id]['page_type']."-sidebar"); ?>
      </ul>
    <?php
      }
    ?>
  </div>
If the template to include is not found (as is the case for additional tabs), only the tabname-sidebar action is executed.

Attached:
  • loadext.php - the copied and patched load.php for my test
  • i18n_specialpages.php - a test of the changes, using functions createSideMenuExt, createNavTabExt, adding the css rule in a header action and calling loadext.php instead of load.php.
My test plugin also includes a condition to determine which tab should be active before register_plugin.
It creates side menu items in Pages and Plugins and a new tab.

I hope you can include this in 3.1!

Martin
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
Include loadtab.php in Core - by mvlcek - 2011-09-07, 23:31:47
Include loadtab.php in Core - by ccagle8 - 2011-09-07, 23:43:32
Include loadtab.php in Core - by mvlcek - 2011-09-08, 00:15:55
Include loadtab.php in Core - by ccagle8 - 2011-09-08, 03:09:02
Include loadtab.php in Core - by mvlcek - 2011-09-08, 05:28:18
Include loadtab.php in Core - by mvlcek - 2011-09-08, 06:06:03
Include loadtab.php in Core - by mvlcek - 2011-10-11, 23:38:48
Include loadtab.php in Core - by ccagle8 - 2011-10-12, 22:34:10
Include loadtab.php in Core - by mvlcek - 2011-10-12, 22:43:23
Include loadtab.php in Core - by leenm - 2011-11-13, 05:18:48
Include loadtab.php in Core - by n00dles101 - 2011-11-13, 05:57:40
Include loadtab.php in Core - by leenm - 2011-11-13, 06:10:29
Include loadtab.php in Core - by mvlcek - 2011-11-13, 06:27:34
Include loadtab.php in Core - by leenm - 2011-11-13, 06:39:56
Include loadtab.php in Core - by n00dles101 - 2011-11-13, 07:14:42
Include loadtab.php in Core - by mvlcek - 2011-11-13, 07:30:30
Include loadtab.php in Core - by n00dles101 - 2011-12-06, 19:52:37
Include loadtab.php in Core - by mvlcek - 2012-01-23, 18:06:55
Include loadtab.php in Core - by leenm - 2012-01-24, 09:41:02
Include loadtab.php in Core - by n00dles101 - 2012-01-25, 01:53:20



Users browsing this thread: 1 Guest(s)