Hello,
I'm modifying the menu.module so that when the user adds a new menu item or edits an existing menu item, then will be able to upload a menu icon; so that the icon will be displayed along side with the text.
However I'm having difficulty uploading the icon.
I've added form elements to the menu_edit_item_form($mid = 0):
$form['menu_icon_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to menu item icon'),
'#default_value' => t(''),
'#description' => t('some text')
);
$form['menu_icon_upload'] = array(
'#type' => 'file',
'#title' => t('Upload menu item icon'),
'#maxlength' => 40,
'#description' => t("some more text."),
);
In the function menu_edit_item_save($edit) I added the following check:
// Check for a new uploaded menu item icon, and use that instead.
if ($file = file_check_upload($edit['menu_icon_upload'])) {
....
}
However, the above evaluates to false all the time.
When I dump $edit['menu_icon_upload'] all I get is the file name. But not the source directory it is to be picked up from.
I've read a lot about adding $form['#attributes'] = array('enctype' => "multipart/form-data"); but truth be told I have no idea where in the menu.module code I would have to add this line. When I add the line to the method menu_edit_item_form($mid = 0) I get a null value for $edit['menu_icon_upload'].
Any assistance is greatly appreciated.
Thanks,
Comments
a while ago...
But how did you go developing this module? It's just what I need...
yeah... it's been some time
Hey sliiiiiide, it's been some time since I did this, and at the time I was coding in Drupal 4.7. The method I did this is quite ugly and I had to make modifications to the menu and a community distributed module called nice_menus (at the time the client was using this module). If you'd like more details send me an email and I can fill you in.