Main Menu Image Links

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
mSalcher
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Sep 09, 2005 10:03 am

Main Menu Image Links

Post by mSalcher » Wed Feb 06, 2008 12:29 pm

hi
first great work on joomla 1.5.
whats the media upload component you are using to enable the multiple selection of files?

i was just playing around a little bit and wondered why it isn't possible to create just image links only within the menu manager

so i started to have a look at the whole mainmenu module.
i tested it within an project of mine and it does good work.

the changes are within the 3 files:

/modules/mod_mainmenu/legacy.php line 144

Code: Select all

code to be replaced:
if ($params->get('menu_images'))
	{
		$menu_params = new stdClass();
		$menu_params = new JParameter($mitem->params);

		$menu_image = $menu_params->def('menu_image', -1);
		if (($menu_image <> '-1') && $menu_image) {
			$image = '<img src="'.JURI::base(true).'/images/stories/' . $menu_image . '" border="0" alt="' . $mitem->name . '"/>';
			
			if( $params->get('menu_images_link') ){
				$txt = '<a href="'.$mitem->url.'" class="'.$menuclass.'" '.$id.'>'.$image.'</a>';
			} else {
  			if ($params->get('menu_images_align')) {
  				$txt = $txt . ' ' . $image;
  			} else {
  				$txt = $image . ' ' . $txt;
  			}
		    }
		}
	}
/modules/mod_mainmenu/mod_mainmenu.php line 41

Code: Select all

code to be added:
$params->def('menu_images_link', 0);
/modules/mod_mainmenu/mod_mainmenu.xml line 58

Code: Select all

code to be added:
	<param name="menu_images_link" type="radio" default="0" label="Menu Icon Link" description="Link on Images Instead of Text">
	       <option value="0">No</option>
		<option value="1">Yes</option>
	</param>
i think this solution would be great if it will be within the next package :)
what are your thoughts about this?

edit:
i just found out that this is only working on legacy list can't find the point to add it to list view.
im currently working on it.

greets
Last edited by mSalcher on Wed Feb 06, 2008 12:52 pm, edited 1 time in total.

User avatar
pvh123
Joomla! Ace
Joomla! Ace
Posts: 1125
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam

Re: Main Menu Image Links

Post by pvh123 » Wed Feb 06, 2008 1:00 pm

I think this is a ver nice thing to have.
May be this can be placed on the Joomla 1.5 wishlist :)
Note: Sending me private messages for personal support, without this been requested, would lead to ignoring any of your posts in future!

User avatar
syl-via
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Mar 11, 2008 12:02 pm
Location: Porto, Portugal

Re: Main Menu Image Links

Post by syl-via » Tue Mar 11, 2008 12:21 pm

Fantastic work mSalcher. Definitely it should be added to the next Joomla editon!!!!

I was wondering if you could help me with the other mainmanu issue. When we choose as a Main Menu Type an Alias which creates a Link to an existing Menu Item, there are no advanced options which would allowed us to set an image to that menu. Do you know how to add this options to that functionality??

Best

Sylwia.
...when i was born the doctor said - "there is something wrong inside that baby head" ...

mSalcher
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Fri Sep 09, 2005 10:03 am

Re: Main Menu Image Links

Post by mSalcher » Tue Mar 11, 2008 4:27 pm

hi thx for the commendation.

hm if i get it right, you would like to create an alias for an already existing item.
that means you will have one item ( e.g. Content ) accessable over 2 different menu links?
this is not a good idea, cause google will indicate this as double content and therefore you
get an bad pagerank.

but i can have a look at it.

regards

User avatar
syl-via
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Mar 11, 2008 12:02 pm
Location: Porto, Portugal

Re: Main Menu Image Links

Post by syl-via » Tue Mar 11, 2008 6:25 pm

no problem :)

I don't know if you already discovered that functionality, but joomla aloud to create alias to already existing items and it works pretty fine. You can find it when you want to create a new item in some menu and while choosing a Menu Type, the last position is Alias. The point is that this option doesn't have "Parameters Advanced", so i thought, since you already discovered how to add an option to "Parameters Advanced" in other menu type, maybe it will be easier for you to discover also this. The stuff which is especially missing there (for me) is the option of image (icon) link, the same what you add above.

And about the google pagerank... well... I think it must be this way in this specific example. The company want exactly the same page, so... let's see.

Anyway... thanks for help.

Best
...when i was born the doctor said - "there is something wrong inside that baby head" ...

nk111
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Tue Mar 18, 2008 4:59 pm

Re: Main Menu Image Links

Post by nk111 » Tue Mar 18, 2008 5:11 pm

Thank you for sharing this!

Here is what I did to get this working in "non legacy mode"...

change in modules/mod_mainmenu/helper.php
line 51

Code: Select all

			    if (array_key_exists($row->parent, $ids)) {
add 1 line:
				    $row->ionly = $params->get('menu_images_link');
				    $menu->addNode($row);
line 295

Code: Select all

if ($iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
			$image = '<img src="'.JURI::base(true).'/images/stories/'.$iParams->get('menu_image').'" alt="" />';
add 3 lines:
			if($tmp->ionly){
				$tmp->name = null;
			}
		} else {
			$image = null;
		}
at least this worked for me...

<edit>
maybe I should mention that these changes must be made in ADDITION to the changes above :)
</edit>
Last edited by nk111 on Wed Mar 19, 2008 7:48 am, edited 1 time in total.

User avatar
syl-via
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Mar 11, 2008 12:02 pm
Location: Porto, Portugal

Re: Main Menu Image Links

Post by syl-via » Wed Mar 19, 2008 12:07 am

Thx a lot. I will check it in themorning.

Best ;-)
...when i was born the doctor said - "there is something wrong inside that baby head" ...

Reclusive
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Thu Jan 17, 2008 9:34 am

Re: Main Menu Image Links

Post by Reclusive » Sun Mar 30, 2008 6:15 am

what changed in 1.5.2?.
I was using this when I was building a site with 1.5.1, worked great.
Then when trying to get event list to work, I clicked load sample to basicly see a example of how it would look, and well. it completely deleted the directory I was working in, the entire subdirectory with the site in it was deleted (bummer)

so I came back to joomla.org to get the install again, saw they had a new version so i got that, proceeded to rebuild the site, (lucky my template that I was working on was saved on hd) when I went to get the menu working, I used this code again, and well, its not working the same.
I use a horizontal menu along the top, and I have to fit within a specific width to allow allvideos reloaded to be on the top of the page aswell (site for a band).
and I get 2 difrent problems.
first if I set the menu as horizontal I get a stupid gradient red to black around my image and and makes the link area about 2.5 times larger (not allowing me to fit all my options up there.
second problem is, If i set it as list, it displays both text and image with a boarder around the image

Never had the problem in 1.5.1 but cant get around it in 1.5.2

http://www.reclusiveproductions.com/Neg ... e&Itemid=1

cyrus61
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Apr 13, 2008 4:00 pm

Re: Main Menu Image Links

Post by cyrus61 » Sun Apr 13, 2008 4:17 pm

This piece of code was exactly what I was looking for. Unfortunately there appears to be a little bug in it, whereby it does not respect the "On Click, Open in" options on the "Menu Item: [Edit]" screen (Joomla 1.5 screen) .

What the code does now is always navigate to the link set on the image in the same browser window. You can no longer open the link in a new window (with or without navigation)

To fix this, in place of this line of code

$txt = '<a href="'.$mitem->url.'" target="_blank" class="'.$menuclass.'" '.$id.'>'.$image.'</a>';

inside the

if( $params->get('menu_images_link') ){

statement, I added the following switch statement instead

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

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

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

default : // formerly case 2
// open in parent window
$txt = '<a href="' . $mitem->url . '" class="' . $menuclass . '" ' . $id . '>' .$image. '</a>';
break;
}

which I lifted from a few lines above in the legacy.php file and slightly modified.

Hopefully this will save someone else some time if they run into the same situation.

cyrus

ps there's probably a better way to code this or integrate it in but I'm not a PHP coder. I just pieced this together from the other code I saw when I figured out how it was working.

aesthitic
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Mon Jul 02, 2007 2:02 am

Re: Main Menu Image Links

Post by aesthitic » Wed Jul 23, 2008 3:46 am

How about different images for different templates? Ie. A beach hut for an image of "home" menu item for a page with a beach template, and then an image of a castle for "home" menu item in another page with another template.

Is this possible?

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Sun Oct 05, 2008 1:34 am

Everytime you create a new link you can assign an image to it just like you can assign a template to it.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

donporter
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Thu Jun 05, 2008 9:01 pm

Re: Main Menu Image Links

Post by donporter » Fri Oct 24, 2008 6:59 pm

Thanks to both nk111 and mSalcher:
nk111 wrote:Thank you for sharing this!

Here is what I did to get this working in "non legacy mode"...

<edit>
maybe I should mention that these changes must be made in ADDITION to the changes above :)
</edit>
It appears to me that these improvements (both the "legacy mode" and the "non-legacy mode") are indeed included in 1.5.7. EXCEPT that the addition (/modules/mod_mainmenu/mod_mainmenu.php line 41) of

Code: Select all

$params->def('menu_images_link', 0);
is NOT there in 1.5.7. Is that intentional?

Nevertheless, it appears to me that the helper.php code is still not working correctly in 1.5.7 (with or without the suggested line 41 in mod_mainmenu.php).

Here's my problem: I have menu_images and menu_images_link both turned on and images assigned to some mainmenu top level menus (Sections). The radio buttons to turn these on are in the "Other Parameters" panel of the mod_mainmenu Module page in the BackEnd. This is working fine on the Home Page. Trouble is: on any other page, the mainmenu displays as though both menu_images and menu_images_link were off.

More specifically, in /modules/mod_mainmenu/helper.php at line 297, the "if" statement

Code: Select all

		if ($params->get('menu_images') && $iParams->get('menu_image') && $iParams->get('menu_image') != -1)
succeeds when I'm on the Home page, while it fails on all other pages. Furthermore, even if I try to work around that, no matter what I do, the values

Code: Select all

$params->get('menu_images')
 and
 $params->get('menu_images_link')
in helper.php get evaluated correctly (1) for the Home page and incorrectly (0) for all other pages.

I can't see any reason why this mainmenu code should act differently on the Home page from other pages. I really need a fix, so it works on all pages the way it works on the Home page. Help!

donporter
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Thu Jun 05, 2008 9:01 pm

Re: Main Menu Image Links

Post by donporter » Sat Oct 25, 2008 2:09 pm

Solved my own problem here. What I failed to realize was that a different instance of the mainmenu module is in control on the non-Home pages. I have a submenu in the left column that displays the Categories, for example, when I'm on a Section page. I had failed to turn on menu_images and menu_images_link in the Module editor for that instance. All better now.

phillymantis
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Tue Feb 26, 2008 3:57 pm

Re: Main Menu Image Links

Post by phillymantis » Wed Jun 24, 2009 10:52 am

didnt work for me in joomla 1.5.11

saying a parse error

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Wed Jun 24, 2009 9:27 pm

What doesn't work? This functionality is included in the core now.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
ciuly
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Jan 08, 2009 8:39 am
Location: Romania
Contact:

Re: Main Menu Image Links

Post by ciuly » Thu Jun 25, 2009 6:06 pm

mcsmom wrote:What doesn't work? This functionality is included in the core now.
can you be more specific? I'm just started with joomla (Joomla! 1.5.11 Production/Stable [ Vea ] 03-June-2009 03:30 GMT) and I'm trying to convert my static site and I have a horizontal image-menu. I tried a lot of combinations with the internal links (although I need it to be external) but to no avail. the only result I get is
| clickable text [not-clickable-image} | clickable text [not-clickable-image} | etc
whereas I need
| [clickable image] | [clickable image] | etc
some are internel links, some are external links.
thanks

User avatar
ciuly
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Jan 08, 2009 8:39 am
Location: Romania
Contact:

Re: Main Menu Image Links

Post by ciuly » Mon Jun 29, 2009 7:01 am

I managed to solve my problem using the following module: http://extensions.joomla.org/extensions ... 55/details
works pretty nice, dont' forget to set the background color properly when you use transpareny ;)

morcth
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Wed Nov 30, 2005 7:19 am

Re: Main Menu Image Links

Post by morcth » Fri Jul 03, 2009 8:44 am

mcsmom I also do not see how this function is included in the core. When I place an image into the menu and choose to make it linkable, the menu text is still there.

I am looking to make an image menu with different style for inactive, active and rollover. From what I see I will be able to use an transparent gif for the image and using css be able to give each menu item a different beackground for hover and active. Problem is that the text for the menu item is still there like "home" and "contact" . So far I haven't been able to figure out how to get rid of it. : ( Any help would be appreciated.

If i use the module mentioned above, it doesnt look like there is an active style for the menu images. So if contact is the active page... you cant have an image of "contact" in red and the others in white. I need a way where the active link is a different color than the rest.

Josh

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Fri Jul 03, 2009 2:58 pm

You may have somehting in your overrides forcing the text then.
If i add an image to a menu item and then go to the module and say show image and make image linkable i get just the image.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Fri Jul 03, 2009 6:20 pm

Ha! I looked in IE7 and see the problem. Can you please make a report in the issue tracker.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

morcth
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Wed Nov 30, 2005 7:19 am

Re: Main Menu Image Links

Post by morcth » Sun Jul 05, 2009 2:47 pm

Actually for me, you were right. There were two modules using the same menu and I think that was causing a problem. Also it only works in list mode. Not in legacy list, horizontal, or flat. Worked fine in ie7 and ff. Now I am wondering what bug you found ; )

Josh

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Sun Jul 05, 2009 5:17 pm

LOL yeah it definitely does not work in legacy menu styles, but you should not be using them if you can help it.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

tammy2772
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Tue Jul 07, 2009 2:02 am

Re: Main Menu Image Links

Post by tammy2772 » Mon Jul 20, 2009 1:32 pm

I am trying to get my menu images working WITHOUT having the text hyperlinks still next to the image so I've been reading this post and trying to edit my helper.php file. I have tried everything suggested and I still have text hyperlinks next to my images and they are the only way to get to the "pages" they are supposed to lead to. The images do not link anywhere. Can someone please help me figure out how to make this happen?
I know you'll probably need to see files so please let me know which you need to see and I will post them.
The preview so you can see how the images look right now (which by the way, they also need to be re-sized so they look terrible right now!) is http://berkshirecoupon.com/joomla/
By the way, I'm obviously new to Joomla. When the site is complete, does the url need to still include "joomla" or do I need to do something so that it doesn't have to?
Thank you in advance!

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Sun Jul 26, 2009 3:03 am

But does it work in Fire Fox?
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

lucasr
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jul 27, 2009 9:49 am

Re: Main Menu Image Links

Post by lucasr » Mon Jul 27, 2009 9:51 am

Yea, I see the code in the new version, but it doesn't work properly.

OS X w/Firefox

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Main Menu Image Links

Post by mcsmom » Tue Jul 28, 2009 4:36 pm

Make sure you went to the menu module and told it to use linkable images. This is not in the menu item, but in the actual module.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

Krycek
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Sep 10, 2008 2:43 pm
Location: Ankiniz, France
Contact:

Re: Main Menu Image Links

Post by Krycek » Fri Aug 14, 2009 12:16 pm

Hello,

From J! 1.5.9 this solution is somehow integrated in, right ?

Anyway, what I'm looking for is to have my menu with HTML code containing title="Name of the link" filled up, to use the onmouse over tip effect.
Actually it would be rather simple to override output or core hack, modifying code to add that tag. Now, where it is tricky is that I do not know how to call with J! framework the "Name of the link" (I mean the one by which linked are sorted in menu item list on J!'s back-end).

To summarize, code's currently like this :

Code: Select all

<a href="http://********/forum" target="_blank"><img src="/images/stories/ds_chope.png" alt="forum" align="left">
I would like it like this :

Code: Select all

<a href="http://********/forum" title="Join the forum !" target="_blank"><img src="/images/stories/ds_chope.png" alt="forum" align="left">
(Adding title="Join the forum !" in)

In which file and with which framework method shall I do that ?
(Running J! 1.5.14)

Thank you very much in advance for your support !
A bullet may have your name on it, but shrapnel is addressed "to whom it may concern".

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Main Menu Image Links

Post by ooffick » Wed Aug 19, 2009 9:30 am

Mod Note: Bump post deleted, please do not bump your posts.

Did you try a layout overwrite?

Olaf
Olaf Offick - Global Moderator
learnskills.org

Krycek
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Sep 10, 2008 2:43 pm
Location: Ankiniz, France
Contact:

Re: Main Menu Image Links

Post by Krycek » Wed Aug 19, 2009 10:06 am

Thanks for your answer and sorry for the bump.

Well... I ain't mind using layout overdrive. But I have no clue how to call the link name with J! framework.

This is the reason of my main question :
In which file and with which framework method shall I do that ?
A bullet may have your name on it, but shrapnel is addressed "to whom it may concern".

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Main Menu Image Links

Post by ooffick » Wed Aug 19, 2009 1:29 pm

Which Menu Style are you using?

Olaf
Olaf Offick - Global Moderator
learnskills.org


Locked

Return to “Joomla! 1.5 Coding”