i.e.
Make $form['menu']['imagepath']['required'] = FALSE
And remove the validation checks:
$check = is_readable($item['imagepath']);
if (!$check) form_set_error('imagepath', t('File not found.'));

A project I am working on requires images on top level menu items but not for sub-menu's, this modification would enable this to be possible.

Comments

Alex Andrascu’s picture

subscribing...image menus shouldn't take over all the menus

SuperZambezi’s picture

I have this problem too. What file I supposed to edit to get this to work? Thanks.

mustanggb’s picture

imagemenu.admin.inc line 335

From:
'#required' => TRUE,

To:
'#required' => FALSE,

---

imagemenu.admin.inc line 424 and 425

From:
$check = is_readable($item['imagepath']);
if (!$check) form_set_error('imagepath', t('File not found.'));

To:
//$check = is_readable($item['imagepath']);
//if (!$check) form_set_error('imagepath', t('File not found.'));

SuperZambezi’s picture

Thanks, it worked but I was hoping that instead of the image, the text would appear as the link. What I am left with now is one of those no file found squares.

And on a side note, is there any way to have the children menu links appear when the parent menu is selected? I could do this with the normal menus but on ImageMenus they do not appear. Thanks for any help I can get.

Lordnine’s picture

Was a solution ever found for this? I've been looking for a way to use imagemenu and/or pure text links in the same menu system for about a week and this is the closest solution I've found.

juliekj’s picture

I'm looking for the same thing, any info on if this will be happening or not would be greatly appreciated, so that if not I can start looking for another solution

tapesonthefloor’s picture

Status: Active » Needs review

Hey folks.

Here's a simple solution that will allow imagemenu to display non-image menu items as well. Basically, we need it to test if the 'image' field is blank, and, if it is, display the 'title' as a link instead.

Here are the changes we need to make.

The first changes are Network's contribution from #3 above.

imagemenu.admin.inc line 336

From:

'#required' => TRUE,

To:

'#required' => FALSE,

imagemenu.admin.inc line 425 and 426

From:

$check = is_readable($item['imagepath']);
if (!$check) form_set_error('imagepath', t('File not found.'));

To:

// $check = is_readable($item['imagepath']);
// if (!$check) form_set_error('imagepath', t('File not found.'));

We'll next add a bit of code to imagemenu.module. Jump down to the if block at around line 491, which is within the menu item display loop. Within the brackets of this if block (looks like if (!empty($item['path']))) we have the following code:

$output = '<li class="'. $li_class .'"'. $listyle .'><a href="'. url($item['path']) .'" class="'. $a_class .'"><img src="'. 
base_path() . $item['imagepath'] .'" alt="'. check_plain($item['alt']) .'" title="'. check_plain($item['title']) 
.'" name="imagemenu_'. $prefix .'_'. $item['mid'] .'"'. $script .' /></a>'. $menu .'</li>';

This displays a menu item with an image. We need to surround this with a nested if block, telling imagemenu to check for the absence of an 'imagepath' as well. If 'imagepath' is absent, we would like to display a simple text link, thankyouverymuch. Replace the block above with the following:

if (!empty($item['imagepath'])) {

$output = '<li class="'. $li_class .'"'. $listyle .'><a href="'. url($item['path']) .'" class="'. $a_class .'"><img src="'. 
base_path() . $item['imagepath'] .'" alt="'. check_plain($item['alt']) .'" title="'. check_plain($item['title']) 
.'" name="imagemenu_'. $prefix .'_'. $item['mid'] .'"'. $script .' /></a>'. $menu .'</li>';

} else {

$output = '<li class="'. $li_class .'"'. $listyle .'><a href="'. url($item['path']) .'" class="'. $a_class .'">'
. check_plain($item['title']) .'</a>'. $menu .'</li>';

}

Be sure to save/publish/upload both files, and imagemenu should magically do what you want it to do. If something's awry, let me know and I'll happy amend the code above. Also let me know if this should be presented as a patch. I'll happily whip something up.

pobster’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Closing as D6.x is now unsupported.