Members: 16,358
Threads: 38,942
Posts: 160,292
Online: 144

Newest Member: shop30


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etrackerŪ Web-Controlling statt Logfile-Analyse
Old 28.02.2005, 08:44   2 links from elsewhere to this Post. Click to view. #1 (permalink)
Baby Mamber
 
Join Date: Jan 2005
Posts: 10
ssdesign is on a distinguished road
Post Main Menu Image hack

Hi,
After looking at some threads on people discussing how to get an Image to display in front of Main Menu links, I decided to look into it.

I figured out this small hack and it works perfectly.

note: Does not work with solarFlare template (maybe someone can help me here.)

To display an Image in front of Menu Links follow these steps:

Step-1:
Upload the images you want to display for each menu item in the default "stories" folder.

You can do this by going to "Site > Media Manager" and upload the images in the root. (not inside any folder).

Step-2:
  1. Go to "Menu > Main Menu" (or any other menu if yo have).
  2. Select the Menu item to which you add an image by clicking it.
  3. Go to "Parameters Tab".
  4. From the first item called "Menu Image" drpdown, select the image you uploaded for the menu.
  5. Save.

Step-3:
We need to make sure that the Main Menu "Module" is configured to show icon images. This is the cause of many people complaining that inspite of setting right parameters, the images are not showing up.
  1. Modules > Site Modules
  2. Select "Main Menu".
  3. Click the "Parameters Tab" on the right hand side of your screen.
  4. Look out for "Show Menu Icons" and click the "YES" radio button.
  5. Also check the appropriate radio button for "Menu Icon Alignment" to display the icon on either left or right of the menu text.
  6. Save.

Step-4:
So far what we have done will work fine and will display an Image that you specified in the Main Menu.

The problem is, this image does not get a hyperlink.

So for those of you who want to link this image, here is a small hack.
  1. Go to the "Modules" folder in your installation.
  2. Open the file "mod_mainmenu.php" in your text editor. I prefer Scite|Flash .
  3. Go to line 85 which starts with
    PHP Code:
    $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', -);
                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;
                    }
                }
            } 
  4. Replace the entire code above with this:
    PHP Code:
    $txt '<a href="'$mitem->link .'" class="'$menuclass .'" '$id .'>';

    //-------------------------------------------------------------------------------------
    //Main Menu Image Hack by Sajid Saiyed of //http://www.ssdesigninteractive.com/g2
    //-------------------------------------------------------------------------------------
                
    if ( $params->get'menu_images' ) ) {
                
    $menu_params = new stdClass();
                
    $menu_params =& new mosParameters$mitem->params );
                
    $menu_image $menu_params->def'menu_image', -);
                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.= $image;
                    } else {
                        
    $txt .= $image .' '$txt;
                    }
                }
            }
                
    //-------------------------------------------------------------------------------------
    //Main Menu Image Hack end
    //-------------------------------------------------------------------------------------
                
    $txt.= $mitem->name;
                
    $txt.='</a>';
                break;
            } 
  5. Save.

Step-5:
Now you can open your site to see that the Menu Icon has been linked.
I still have to figure out how to use ONLY IMAGE as menu links.

I tried setting BLANK name for Menu Item name but Mambo does not allow to keep the name as blank.

So if someone can help out here, it would be great.

Cheers and hope it works for you.
__________________
::form follows function::
my portfolio | {G2}-Generative Graphics

Last edited by ssdesign : 28.02.2005 at 11:18.
ssdesign is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 28.02.2005, 10:17   #2 (permalink)
Mamber
 
Xirtam's Avatar
 
Join Date: Apr 2004
Posts: 81
Xirtam is on a distinguished road
Send a message via MSN to Xirtam
Default Re: Main Menu Image hack

Looks good !!
I will play with your hack, thank you.
Is there maybe a link so we can see it working?
_X_
__________________
_/ _/ _/ Xirtam
_/ _/ _/ www.ummagumma.nl
_/ _/ _/ Mambo Calendar Modules
Xirtam is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 28.02.2005, 11:08   #3 (permalink)
Baby Mamber
 
Join Date: Jan 2005
Posts: 10
ssdesign is on a distinguished road
Default Re: Main Menu Image hack

Right now I am figuring out how to make IMAGE ONLY menu. Once I get my way around that, I will post the new template which I am working on.
__________________
::form follows function::
my portfolio | {G2}-Generative Graphics
ssdesign is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 28.02.2005, 11:54   #4 (permalink)
Baby Mamber
 
Join Date: Jan 2005
Posts: 10
ssdesign is on a distinguished road
Default Re: Main Menu Image hack

I think I figured it out, If we remove the following line of code from my hack, it will work as Image Only Menu:

PHP Code:
$txt.= $mitem->name
__________________
::form follows function::
my portfolio | {G2}-Generative Graphics
ssdesign is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 16.03.2005, 20:01   #5 (permalink)
Junior Mamber
 
Join Date: Mar 2005
Posts: 38
mailalon is on a distinguished road
Default Re: Main Menu Image hack

problem with this hack is that when you use one text menu and one image menu the new hack make the text menu disappear. any idea how to hack it ?
mailalon is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 21.03.2005, 05:27   #6 (permalink)
Baby Mamber
 
Dragonfly's Avatar
 
Join Date: Feb 2005
Posts: 21
Dragonfly is on a distinguished road
Default Re: Main Menu Image hack

Thanks for the complete guide on this. I was searching the forum and found here finally. Thanks again.
Dragonfly is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07.04.2005, 21:43   #7 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 5
buckster is on a distinguished road
Default Re: Main Menu Image hack

This works great. Only one problem, some of the items in the main menu are not components or older components that do not have extensive parameter settings. Usually they have just a text box. Is there a parameter line for an image in this case?
buckster is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 13.04.2005, 15:39   #8 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 23
p2020 is on a distinguished road
Default Re: Main Menu Image hack

Quote:
Originally Posted by mailalon
problem with this hack is that when you use one text menu and one image menu the new hack make the text menu disappear. any idea how to hack it ?
If you add the following if statement:

PHP Code:
if (!strstr($mitem->name,'blank')) 
before this line

PHP Code:
$txt.= $mitem->name
and include the word "blank" in the menu name, all other menus work.

Thanks for this hack!
p2020 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02.05.2005, 15:52   #9 (permalink)
Baby Mamber
 
Join Date: Apr 2005
Posts: 2
abdulmambo is on a distinguished road
Default Re: Main Menu Image hack

For those like me who struggle with scripting, I thought of posting the complete code with amendments:

----------------------------------------------------------------------------------------------------
$txt = '<a href="'. $mitem->link .'" class="'. $menuclass .'" '. $id .'>';
}

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 = $image;
} else {
$txt .= $image .' '. $txt;
}
}
}
if (!strstr($mitem->name,'blank'))
$txt.= $mitem->name;
$txt.='</a>';
return $txt;
break;
}
-----------------------------------------------------------------------------------------------------

Thank you ssdesign (Flash Guru) for the original solution and to everyone else for the fine-tuning. I have a question, does anyone know when using the above is it possible to do an image swap. If not with this solution then can anyone suggest how an image swap can be incorporated with the main menu image hack above.

Thank you all

Abs

Last edited by abdulmambo : 02.05.2005 at 16:27. Reason: Spelling check and additional comments
abdulmambo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 17.05.2005, 23:21   #10 (permalink)
Expert Mamber
 
xjumper84's Avatar
 
Join Date: May 2005
Posts: 257
xjumper84 is on a distinguished road
Default Re: Main Menu Image hack

I tried this code and it didn't work for me.. anyone have the same problems ? or maybe i'm not taking out enough of the code.. it left me with a huge bare across the top of the page making it look like the main menu was the entire page

You have to make sure you don't have a double break; at the end i guess.. just some tips.. i suck at this

Last edited by xjumper84 : 18.05.2005 at 00:37.
xjumper84 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.mambers.com/template-discussions/26417-main-menu-image-hack.html
Posted By For Type Date
Menu con immagini This thread Refback 01.03.2008 13:21
Menu con immagini This thread Refback 01.03.2008 12:46

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to add new menu item in Main Menu Max Kaar Mambo 4.5 Installation and Upgrades 8 06.09.2006 03:02
Main Menu Hack... Anyone have an idea about this? Thanks! meek Module 'How Do I' Questions 1 27.02.2005 00:41
Interaction between main menu and top menu?? mirrie36 Mambo 4.5.1 'How Do I' Questions 0 22.02.2005 17:54
3 Level deep Main menu thomas9 Mambo 4.5.1 'How Do I' Questions 4 14.12.2004 23:33
linking direct from main menu to main body mikeh1980 Mambo 4.5 'How Do I' Questions 7 17.06.2004 15:52


All times are GMT +2. The time now is 10:46.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.