Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Using unset for menu items

  1. #1
    tickletoe is offline Member
    Join Date
    Feb 2011
    Location
    London, UK
    Posts
    13

    Default Using unset for menu items

    I can't see why this won't work, any help would be much appretiated.

    I have this code in a file called custom\Extension\modules\Contacts\Ext\Menus\menu.e xt.php

    <?php
    foreach($module_menu as $item_id => $item_defs) {
    unset($module_menu[$item_id]);
    }

    ?>

    I have repaired and rebuilt but it has no effect on the contacts menu. Shouldn't this remove all menu options? I can add menu items in this file and it works, but the unset doesn't?

    If I add this code to modules\Contacts\Menu.php it works.

    I am using 6.1 community edition.

    Many thanks for any help,
    Scott

  2. #2
    tickletoe is offline Member
    Join Date
    Feb 2011
    Location
    London, UK
    Posts
    13

    Default Re: Using unset for menu items

    there is no space in the file name it is menu.ext.php

  3. #3
    tickletoe is offline Member
    Join Date
    Feb 2011
    Location
    London, UK
    Posts
    13

    Default Re: Using unset for menu items

    I have displayed the array var_dump($module_menu) in a file located in custom\Extension\modules\Contacts\Ext\Menus\menu.e xt.php and the array has a count of 0.

    If I display it in modules\Contacts\Menu.php then it has 4 occurrences.

    I thought I could manipulate this array from with the menu.ext.php but it appears I can only add items and not take them away. Is there something I am not doing to expose the right array to my code?

    Many thanks for your help.

  4. #4
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Using unset for menu items

    The way i do it is

    in a file custom/Extension/modules/Accounts/Ext/Menus/custom.php

    <?php
    global $mod_strings, $app_strings;
    $module_menu = array(); #clear original menu
    if(ACLController::checkAccess('Accounts', 'edit', true))$module_menu[]=Array("index.php?module=Accounts&action=EditView& return_module=Accounts&return_action=index", $mod_strings['LNK_NEW_ACCOUNT'],"CreateAccounts", 'Accounts');
    if(ACLController::checkAccess('Accounts', 'list', true))$module_menu[]=Array("index.php?module=Accounts&action=index&ret urn_module=Accounts&return_action=DetailView", $mod_strings['LNK_ACCOUNT_LIST'],"Accounts", 'Accounts');
    if(ACLController::checkAccess('Accounts', 'import', true))$module_menu[]=Array("index.php?module=Import&action=Step1&impor t_module=Accounts&return_module=Accounts&return_ac tion=index", $app_strings['LBL_IMPORT'],"Import", 'Accounts');
    $module_menu[]= Array("index.php?module=Documents&action=DetailVie w&record=98eb6cd9-4e57-e159-2267-49f087012da9",$mod_strings['LNK_TEMPLATE'],"Documents");

    ?>

    then repair
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  5. #5
    tickletoe is offline Member
    Join Date
    Feb 2011
    Location
    London, UK
    Posts
    13

    Default Re: Using unset for menu items

    Hi Mike, Thanks for the reply. I tried it and I ended up with duplicate menu options. It is as if the menu is built up of two arrays, the one built in modules\Contacts\Menu.php and the one from custom\Extension\modules\Contacts\Ext\Menus\custom .php. I have displayed the array count and it is like this:

    Begining of Menu.php - array(0)
    End of Menu.php - array(4)
    Beginning of custom.php - array(0)
    End of custom.php - array(3)

    And I end up with 7 items on my menu. I can't figure it out.

    I am using 6.1.2 CE and PHP 5.2.6

    Many Thanks

  6. #6
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Using unset for menu items

    Quote Originally Posted by tickletoe View Post
    Hi Mike, Thanks for the reply. I tried it and I ended up with duplicate menu options. It is as if the menu is built up of two arrays, the one built in modules\Contacts\Menu.php and the one from custom\Extension\modules\Contacts\Ext\Menus\custom .php. I have displayed the array count and it is like this:

    Begining of Menu.php - array(0)
    End of Menu.php - array(4)
    Beginning of custom.php - array(0)
    End of custom.php - array(3)

    And I end up with 7 items on my menu. I can't figure it out.

    I am using 6.1.2 CE and PHP 5.2.6

    Many Thanks
    Can you post your code here please and I'll give it a try
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  7. #7
    tickletoe is offline Member
    Join Date
    Feb 2011
    Location
    London, UK
    Posts
    13

    Default Re: Using unset for menu items

    Hi Mike,
    Attached are two files. Menu.ext.php comes from custom\Extension\modules\Contacts\Ext\Menus
    and Menu.php comes from modules\Contacts and hasn't been modified.
    I used var_dump($module_menu); at various points to display the array size, but I have taken these out.
    Many thanks again.
    Attached Files Attached Files

  8. #8
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Using unset for menu items

    Quote Originally Posted by tickletoe View Post
    Hi Mike,
    Attached are two files. Menu.ext.php comes from custom\Extension\modules\Contacts\Ext\Menus
    and Menu.php comes from modules\Contacts and hasn't been modified.
    I used var_dump($module_menu); at various points to display the array size, but I have taken these out.
    Many thanks again.
    I have tried your file in 5.5 and it works fine

    Tried it in 6.1 and as you say it doesn't

    I'll have another look tomorrow and see if I can make it work
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  9. #9
    mak111 is offline Sugar Community Member
    Join Date
    Jul 2010
    Posts
    18

    Default Re: Using unset for menu items

    Hi,

    Use simply menu.php in custom/ext.modulename/ext/menus/

    the above path should not contain any file with men.ext.php. remember in sugar 6.1.2 shortcut menu files either replace entirely, or add to the menu items available under the “Actions” list on the module tabs.


    Regards
    Mak

  10. #10
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: Using unset for menu items

    Have you tried to rewrite menu items directly in the /modules/Contacts/Menu.php?
    Letrium ltd. - Only high quality service
    http://letrium.com

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to hide context menu items in Emails?
    By arun_raja in forum Developer Help
    Replies: 2
    Last Post: 2011-02-18, 10:16 AM
  2. How to Order Two Custom Menu Items?
    By jjwdesign in forum Developer Help
    Replies: 4
    Last Post: 2010-03-12, 08:20 AM
  3. Homepage menu items
    By shadowBean in forum Translators
    Replies: 1
    Last Post: 2010-02-21, 12:29 PM
  4. Hiding Menu Items
    By Brobs in forum Developer Help
    Replies: 1
    Last Post: 2010-02-04, 04:16 PM
  5. Closed items in menu screens
    By jon_d_wilkinson in forum General Discussion
    Replies: 0
    Last Post: 2005-12-21, 04:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •