Home Tutorial Perbaikan pada masalah status aktif submenu
arimurti.com
E-mail
Perbaikan pada masalah status aktif submenu
Tutorial
John de koplo, Monday, 18 February 2008 23:32

Pada joomla 1.0.x terdapat masalah status aktif submenu yang tidak bisa tampil, and here is how to fix it :

 1. Buka /modules/mod_mainmenu.php

2. Edit :

/**
* Utility function for writing a menu link
*/
function mosGetMenuLink( $mitem, $level=0, &$params, $open=null ) {
  global $Itemid, $mosConfig_live_site, $mainframe;

  $txt = '';
      
  switch ($mitem->type) {
    case 'separator':
    case 'component_item_link':
      break;
         
    case 'url':
      if ( eregi( 'index.php\?', $mitem->link ) ) {
        if ( !eregi( 'Itemid=', $mitem->link ) ) {
          $mitem->link .= '&Itemid='. $mitem->id;
        }
      }
      break;
            
    case 'content_item_link':
    case 'content_typed':
      // load menu params
      $menuparams = new mosParameters( $mitem->params, $mainframe->getPath( 'menu_xml', $mitem->type ), 'menu' );
            
      $unique_itemid = $menuparams->get( 'unique_itemid', 1 );
            
      if ( $unique_itemid ) {
        $mitem->link .= '&Itemid='. $mitem->id;
      } else {
        $temp = split('&task=view&id=', $mitem->link);
               
        if ( $mitem->type == 'content_typed' ) {
          $mitem->link .= '&Itemid='. $mainframe->getItemid($temp[1], 1, 0);
        } else {
          $mitem->link .= '&Itemid='. $mainframe->getItemid($temp[1], 0, 1);
        }
      }
      break;

    default:
      $mitem->link .= '&Itemid='. $mitem->id;
      break;
  }

  // Active Menu highlighting
  $current_itemid = $Itemid;
  if ( !$current_itemid ) {
    $id = '';
  } else if ( $current_itemid == $mitem->id ) {
    //---Sal
    if ($level > 0 ) {
      $id = 'id="active_submenu'. $params->get( 'class_sfx' ) .'"';
    } else {
      $id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"';
    }
    //---
  } else if( $params->get( 'activate_parent' ) && isset( $open ) && in_array( $mitem->id, $open ) )  {
    //---Sal
    if ($level > 0 ) {
      $id = 'id="active_submenu'. $params->get( 'class_sfx' ) .'"';
    } else {
      $id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"';
    }
    //---
  } else {
    $id = '';
  }

  if ( $params->get( 'full_active_id' ) ) {
    // support for `active_menu` of 'Link - Component Item'   
    if ( $id == '' && $mitem->type == 'component_item_link' ) {
      parse_str( $mitem->link, $url );
      if ( $url['Itemid'] == $current_itemid ) {
        //---Sal
        if ($level > 0 ) {
          $id = 'id="active_submenu'. $params->get( 'class_sfx' ) .'"';
        } else {
          $id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"';
        }
        //---
      }
    }
         
    // support for `active_menu` of 'Link - Url' if link is relative
    if ( $id == '' && $mitem->type == 'url' && strpos( 'http', $mitem->link ) === false) {
      parse_str( $mitem->link, $url );
      if ( isset( $url['Itemid'] ) ) {
        if ( $url['Itemid'] == $current_itemid ) {
          $id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"';
        }
      }
    }
  }
      
  // replace & with amp; for xhtml compliance
  $mitem->link = ampReplace( $mitem->link );

  // run through SEF convertor
  $mitem->link = sefRelToAbs( $mitem->link );

  $menuclass = 'mainlevel'. $params->get( 'class_sfx' );
  if ($level > 0) {
    $menuclass = 'sublevel'. $params->get( 'class_sfx');
  }

  // replace & with amp; for xhtml compliance
  // remove slashes from excaped characters
  $mitem->name = stripslashes( ampReplace($mitem->name) );

  switch ($mitem->browserNav) {
    // cases are slightly different
    case 1:
      // open in a new window
      $txt = '<a href="'. $mitem->link .'" target="_blank" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';
      break;

    case 2:
      // open in a popup window
      $txt = "<a href=\"#\" onclick=\"javascript: window.open('". $mitem->link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\" class=\"$menuclass\" ". $id .">". $mitem->name ."</a>\n";
      break;

    case 3:
      // don't link it
      $txt = '<span class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</span>';
      break;

    default:   
      // open in parent window
      $txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>'. $mitem->name .'</a>';
      break;
  }

  if ( $params->get( 'menu_images' ) ) {
    $menu_params = new stdClass();
    $menu_params = new mosParameters( $mitem->params );
    $menu_image = $menu_params->def( 'menu_image', -1 );
    if ( ( $menu_image != '-1' ) && $menu_image ) {
      $image = '<img src="'. $mosConfig_live_site .'/images/stories/'. $menu_image .'" border="0" alt="'. $mitem->name .'"/>';
      if ( $params->get( 'menu_images_align' ) ) {
        $txt = $txt .' '. $image;
      } else {
        $txt = $image .' '. $txt;
      }
    }
  }

  return $txt;
}
 

3. Ubah CSS :

    a.sublevel#active_submenu{
        color:#D96D6D; (or whatever you want)
    }

Comments
Search
Gimana BOZ..
Uclux 2008-07-29 00:06:56

Maksudnya edit disebelah manannya BOZ..?
Editan/script ini ditaruh setelah
apa?
Atau script yang ada di mod_mainmenu.php diilangin semua dan diganti
dengan script ini atau gimana?

makasih..
Edit Yg Manaaa?
eko prasetyo 2008-11-27 19:12:07

Iya, kok gak jelas yg diedit yg mana? :?
Klo pengalamanku, komponen SEF
diuninstall udah beres tuh.
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated on Wednesday, 10 June 2009 17:08  

JUG Indonesia

Id-joomla.com adalah situs resmi Joomla User Group (JUG) Indonesia dan Joomla Translation Team

Download Terjemahan Joomla terakreditasi dari JoomlaCode dan laporkan bugs, ide dan saran nya di Sub Forum Hanacaraka

Login

Web
ID-Joomla
Banner
Banner
Dengarkan siaran radio ID-Joomla   Chatroom ID-Joomla   Facebook Page ID-Joomla
We have 1451 guests and 1 member online
Joomla! is the trademark of Open Source Matters, Inc in the United States and other countries. The Joomla! name is used under a limited license granted by Open Source Matters.
Id-joomla.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project