bigbenbuilders Posted September 12, 2009 Share Posted September 12, 2009 Here is the code I have it where is is taking image 1 which is an arrow but on click when the parent clicked and child is open I need the parent image to show an arrow down... <?php /** * @version $Id: mod_mainmenu.php,v 1.2 2005/08/02 08:21:53 akede Exp $ * @package Mambo * @copyright (C) 2000 - 2005 Miro International Pty Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * Mambo is Free Software */ /** ensure this file is being included by a parent file */ defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); if (!defined( '_MOS_MAINMENU_MODULE' )) { /** ensure that functions are declared only once */ define( '_MOS_MAINMENU_MODULE', 1 ); /** * Utility function for writing a menu link */ function mosGetMenuLink( $mitem, $level=0, &$params ) { global $Itemid, $mosConfig_live_site, $mainframe; $txt = ''; switch ($mitem->type) { case 'separator': case 'component_item_link': break; case 'content_item_link': $temp = split("&task=view&id=", $mitem->link); $mitem->link .= '&Itemid='. $mainframe->getItemid($temp[1]); break; case 'url': if ( eregi( 'index.php\?', $mitem->link ) ) { if ( !eregi( 'Itemid=', $mitem->link ) ) { $mitem->link .= '&Itemid='. $mitem->id; } } break; case 'content_typed': default: $mitem->link .= '&Itemid='. $mitem->id; break; } // Active Menu highlighting $current_itemid = $Itemid; if ( !$current_itemid ) { $id = ''; } else if ( $current_itemid == $mitem->id ) { $id = 'id="active_menu'. $params->get( 'class_sfx' ) .'"'; } else { $id = ''; } $mitem->link = ampReplace( $mitem->link ); if ( strcasecmp( substr( $mitem->link,0,4 ), 'http' ) ) { $mitem->link = sefRelToAbs( $mitem->link ); } $menuclass = 'mainlevel'. $params->get( 'class_sfx' ); if ($level > 0) { $menuclass = 'sublevel'. $params->get( 'class_sfx'); } 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: // formerly case 2 // 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; } /** * Vertically Indented Menu */ function mosShowVIMenu( &$params ) { global $database, $my, $cur_template, $Itemid; global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_shownoauth; /* If a user has signed in, get their user type */ $intUserType = 0; if($my->gid){ switch ($my->usertype) { case 'Super Administrator': $intUserType = 0; break; case 'Administrator': $intUserType = 1; break; case 'Editor': $intUserType = 2; break; case 'Registered': $intUserType = 3; break; case 'Author': $intUserType = 4; break; case 'Publisher': $intUserType = 5; break; case 'Manager': $intUserType = 6; break; } } else { /* user isn't logged in so make their usertype 0 */ $intUserType = 0; } if ($mosConfig_shownoauth) { $sql = "SELECT m.* FROM #__menu AS m" . "\nWHERE menutype='". $params->get( 'menutype' ) ."' AND published='1'" . "\nORDER BY parent,ordering"; } else { $sql = "SELECT m.* FROM #__menu AS m" . "\nWHERE menutype='". $params->get( 'menutype' ) ."' AND published='1' AND access <= '$my->gid'" . "\nORDER BY parent,ordering"; } $database->setQuery( $sql ); $rows = $database->loadObjectList( 'id' ); // indent icons switch ( $params->get( 'indent_image' ) ) { case '1': // Default images $imgpath = $mosConfig_live_site .'/images/M_images'; for ( $i = 1; $i < 7; $i++ ) { $img[$i] = '<img src="'. $imgpath .'/indent'. $i .'.png" alt="" />'; } break; case '2': // Use Params $imgpath = $mosConfig_live_site .'/images/M_images'; for ( $i = 1; $i < 7; $i++ ) { if ( $params->get( 'indent_image'. $i ) == '-1' ) { $img[$i] = NULL; } else { $img[$i] = '<img src="'. $imgpath .'/'. $params->get( 'indent_image'. $i ) .'" alt="" />'; } } break; case '3': // None for ( $i = 1; $i < 7; $i++ ) { $img[$i] = NULL; } break; default: // Template $imgpath = $mosConfig_live_site .'/templates/'. $cur_template .'/images'; for ( $i = 1; $i < 7; $i++ ) { $img[$i] = '<img src="'. $imgpath .'/indent'. $i .'.png" alt="" />'; } break; } $indents = array( // block prefix / item prefix / item suffix / block suffix array( '<table width="100%" border="0" cellpadding="0" cellspacing="0">', '<tr align="left"><td>' , '</td></tr>', '</table>' ), array( '', '<div style="padding-left: 4px">'. $img[1] , '</div>', '' ), array( '', '<div style="padding-left: 8px">'. $img[2] , '</div>', '' ), array( '', '<div style="padding-left: 12px">'. $img[3] , '</div>', '' ), array( '', '<div style="padding-left: 16px">'. $img[4] , '</div>', '' ), array( '', '<div style="padding-left: 20px">'. $img[5] , '</div>', '' ), array( '', '<div style="padding-left: 24px">'. $img[6] , '</div>', '' ), ); // establish the hierarchy of the menu $children = array(); // first pass - collect children foreach ($rows as $v ) { $pt = $v->parent; $list = @$children[$pt] ? $children[$pt] : array(); array_push( $list, $v ); $children[$pt] = $list; } // second pass - collect 'open' menus $open = array( $Itemid ); $count = 20; // maximum levels - to prevent runaway loop $id = $Itemid; while (--$count) { if (isset($rows[$id]) && $rows[$id]->parent > 0) { $id = $rows[$id]->parent; $open[] = $id; } else { break; } } mosRecurseVIMenu( 0, 0, $children, $open, $indents, $params ); } /** * Utility function to recursively work through a vertically indented * hierarchial menu */ function mosRecurseVIMenu( $id, $level, &$children, &$open, &$indents, &$params ) { global $Itemid; if (@$children[$id]) { $n = min( $level, count( $indents )-1 ); echo "\n".$indents[$n][0]; foreach ($children[$id] as $row) { echo "\n".$indents[$n][1]; echo mosGetMenuLink( $row, $level, $params ); // show menu with menu expanded - submenus visible if ( !$params->get( 'expand_menu' ) ) { if ( in_array( $row->id, $open )) { mosRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $params ); } } else { mosRecurseVIMenu( $row->id, $level+1, $children, $open, $indents, $params ); } echo $indents[$n][2]; } echo "\n".$indents[$n][3]; } } ?> Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 12, 2009 Author Share Posted September 12, 2009 this is on the Vertically Indented Menu Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 12, 2009 Author Share Posted September 12, 2009 any suggestions Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 12, 2009 Author Share Posted September 12, 2009 I think is this where it needs to be done with an if or else then echo? 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; } Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 12, 2009 Author Share Posted September 12, 2009 is there a javascript code I could use to get this to happen? Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 13, 2009 Author Share Posted September 13, 2009 any luck guys Quote Link to comment Share on other sites More sharing options...
bigbenbuilders Posted September 16, 2009 Author Share Posted September 16, 2009 friendly bump Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.