Hello

First of al, thanks for the effort that you put in this small but verry handy module.

I use the D7 dev version now to place a in the title of some menu items. Although everything is working great, i get an error when i am on the edit form of a menu item "Notice: Undefined index: menu in menu_html_form_alter()".

Any thoughts?

grts

Frederic wbase

Comments

elwyn’s picture

I ran into the same issue today. Drupal 7.15, Menu HTML 7.x-1.x-dev

As well as the error mentioned above, the checkbox was not being set with the stored value.

I've fixed the issue by modifying menu_html.module.

/**
 * hook_form_alter
 */
function menu_html_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'menu_edit_item' || strpos($form_id, '_node_form') > 0 && isset($form['menu'])) {
      if ($form_id == 'menu_edit_item') {
        $currently_checked = isset($form['options']['#value']['html']) ? $form['options']['#value']['html'] : 0;
      }
      else {
        $currently_checked = isset($form['menu']['link']['options']['#value']['html']) ? $form['menu']['link']['options']['#value']['html'] : 0;
      }
      $form['menu']['html'] = array(
        '#type' => 'checkbox',
        '#title' => t('Allow html'),
        '#default_value' => $currently_checked,
        '#description' => t('If you want to add html tags to the title of a menu, enable this. This should only be accessible to trusted users.'),
        );
    }
}

Note in the code above I have also applied a bug fix for this issue: https://drupal.org/node/963256#comment-6339234 (checking if this content type actually has menus enabled for it) (the added "&& isset($form['menu'])").

Sorry I'm not sure how to make this into a .patch file! Hope that helps someone out.

myselfhimself’s picture

Hello,

this patch works for me and helped me fix the following error:

Notice : Undefined index: #item dans menu_html_form_alter() (ligne 7 dans /var/www/example.com/releases/20121004124149/www/sites/all/modules/contrib/menu_html/menu_html.module).

Thank you very much !

vacilando’s picture

Same problem :-(

axe312’s picture

Status: Active » Reviewed & tested by the community

#2 also fixes the problem for me! pls add to core!

vacilando’s picture

#2 is a solid solution; please apply it at least in dev.

dadderley’s picture

This works for me.
Now if only I could make this happen in a superfish menu I would be in business,

dadderley’s picture

It does not work with superfish 7.x-1.8
But it will work with the newest dev release of Superfish.
superfish 7.x-1.x-dev
Last packaged version: 7.x-1.9-beta5+1-dev
Last updated: December 9, 2012 - 17:32

Very cool.

energee’s picture

Issue tags: +Patch Rolled
StatusFileSize
new1.49 KB

Rolled for git/patch apply

drzraf’s picture

rerolled to apply against 7.x-1.x + fixes

  • isset($form['menu']) is often wrong
  • menu_html_menu_link_alter prototype takes only 1 argument
  • we can do smarter tests
drzraf’s picture

Status: Reviewed & tested by the community » Needs review
drzraf’s picture

StatusFileSize
new2.33 KB

brand new implementation
enjoy

gimpel’s picture

@drzraf: your patch from #10 works fine, the one from #12 exhibits the initial issue again here.

drzraf’s picture

fixed for both forms (menu-item-form and node-edit-form)
Added a maxlength to 255 (VARCHAR(255)) instead of 128 so we have more place allowed for html menu items than for classic menu.

Last note: a hint to special_menu_items could be useful as this is the only way to put a <span> instead of having the HTML surronded by a <a>.

carolpettirossi’s picture

The patches from #12 and #14 haven't worked for me.
I've applied patch from #10 and it works fine in Drupal 7.22.

drzraf’s picture

could you please tell me what was the notice and which form were you filling ?
The module in #14 is the way to go: it's enhanced and uses the proper hooks.

LaurenW’s picture

I am seeing the same error above, but am not knowledgable in how to apply patches. Has this been incorporated into a dev version yet?

Thanks!

daveparrish’s picture

StatusFileSize
new2.43 KB

#14 worked well for me except that I had a notice due to $form['options']['#value']['html'] not existing when I would edit a menu item.

I rerolled a patch with that fix and a few changes to match Drupal coding standards.

BTW, I patched the module by using git to download the module (git clone http://git.drupal.org/project/menu_html.git), checked out the 7.x branch (git checkout 7.x-1.x), and then applied the patch (git apply 1716906-14-clean-hook-implementation.patch). I hope that helps some folks.

dooug’s picture

Component: User interface » Code

the patch in #18 worked for me. It also resolved this issue: #1991962: Remember 'allow html' setting.

I can also second comment #8 that you'll need to upgrade to Superfish 7.x-1.9 for these to work together.

paulrooney’s picture

#18 worked for me as well. Thanks!

Exploratus’s picture

#18 worked for me also.

dooug’s picture

Status: Needs review » Reviewed & tested by the community
byue’s picture

Allow HTML checkbox is gone after apply patch 18

gilsbert’s picture

Hi.

This issue is still happening on the last dev version (7.x-1.x-dev - 2013-set-30).

I also confirm #23. The patch #18 removes the warning/notice message but it does make the option "allow HTML" disappear.

gilsbert’s picture

Status: Reviewed & tested by the community » Needs work

Updating the status!

jeremymcminn’s picture

Any updates on this?

daveparrish’s picture

Which page is "Allow HTML" not showing up? It should show on both the node forms and the menu item form. For the node forms, the content type needs to have a menu enabled. I'm happy to fix the issue, but I haven't been able to reproduce.

gilsbert’s picture

Hi.

I did a new test today. The "allow html" option is showing at menu item and node forms.
I dont know what I did different... maybe a "flush cache"?

That way I'm changing my report to: fixed!

Will patch #18 get incorpored into the official release?

Regards,
Gilsberty

daveparrish’s picture

Status: Needs work » Reviewed & tested by the community

I'm not the maintainer. Perhaps gagarine can help get the patch incorporated.

I've changed the status to "reviewed & tested by the community". Hopefully that will bring this issue to the attention of the maintainers.

gagarine’s picture

Status: Reviewed & tested by the community » Fixed
gilsbert’s picture

Hi.

I tested 7.x-1.0 of october's 19th and the issue is gone.
Thank you very much.

Regards,
Gilsberty

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

imanoop’s picture

Issue summary: View changes

To "fix" this problem you must open Structure > Content Types > Page again and just edit and save it. Error message will be gone.
You will have to do this for all the content types to resolve this completely.
Copied!

Thanks,
Anoop Singh