In Joomla 3.6 let's say a menu with this structure (menu->submenu)
Menu (alias = main-menu)
-->Submenu-1 (alias = submenu-1)
-->Submenu-2 (alias = submenu-2)
the flink (or route) of submenus become
domain.com/main-menu/submenu-1, domain.com/main-menu/submenu-2
I want to use the submenu alias alone without adding main-menu/
to get domain.com/submenu-1
how can I fix it ?
thank you
You can create another menu in menu manager - call it for example 'Hidden Menu', and create there Submenu-1 element [it needs to be 1 level element - not a child].
Then in your 'Main Menu' create item Submenu-1 [as child] - set it type to 'menu item alias', and select your Submenu-1 item from Hidden menu.
so structure will look
Hidden Menu
|- Submenu-1 (menu item)
Main Menu
|- parent
|-- Submenu-1 (menu item alias)
Related
I have an AppleScript script that will find all of the menu items from all of the menu bar menus. I've filtered out each separator, so I have just the commands, and now I'd like to find out how to find out which menu items are disabled. Does anybody know how I could do that?
Update:
Here's the code I have to get the names of each menu command. It's working fine, and I tried to get the menu items that were enabled in the getAppMenuItems, but it just returned all the menu items, missing values too.
set appName to "Script Editor"
set allMenus to {}
set everything to {}
set onlyEnabled to {}
tell application "System Events" to tell process appName
set allMenus to name of every menu of menu bar 1
end tell
repeat with menuName in allMenus
set the end of everything to strings of getAppMenuItems(appName, menuName, onlyEnabled)
end repeat
on getAppMenuItems(appProcess, appMenus, enabledItems)
tell application "System Events" to tell process appProcess
(*
# Get all menu items
set theItems to every menu item of menu appMenus of menu bar 1
repeat with i from 1 to number of items in theItems
set thisItem to item i of theItems
if thisItem is not enabled then
log ("Item: " & name of thisItem & " is enabled")
set the end of enabledItems to the name of thisItem
end if
end repeat
*)
return name of every menu item of menu appMenus of menu bar 1
end tell
end getAppMenuItems
# From the commented part of the 'getAppMenuItems' function above.
# When that part of the function is uncommented, I just get everything,
# missing values and all
onlyEnabled
# Edit Menu
item 4 of everything
(* Outputs: Half of these items are not enabled
{"Undo", "Redo", "Cut", "Copy", "Paste", "Paste and Match Style", "Paste Reference", "Delete", "Select All", "Complete", "Find", "Spelling and Grammar", "Substitutions", "Transformations", "Speech", "Start Dictation…", "Emoji & Symbols"} *)
In order to get the properties of a menu item, you first need to get a reference to that menu item. You would then need to go through the various menu items and build lists or records of those that meet your criteria, so that the references can be used as needed.
From the comments, general-purpose handlers to click at or get menu references by using a list of the menu hierarchy would serve your purpose, so those would be something like:
on run -- examples
#clickMenu at {"Finder", "View", 10, "Name"} -- note that there are 2 "Clean Up" items
set menuRef to getMenuReference for {"Script Editor", "File", "New"}
log result
clickMenu at menuRef -- clickMenu at {"Script Editor", "File", "New"} can also be used
end run
to getMenuReference for menuList -- Get a reference to a menu item in an application's main menu.
(*
The menu hierarchy is described in the menuList parameter.
The last menu item doesn't need to be exact, just close enough for a match.
Menu items can also be integer indexes (separators are counted).
When using an index, note that menus can contain dynamic or hidden items.
parameters: menuList [list] -
item 1 [text]: the application name
item 2 [text]: the menu bar item name
item(s) 3+ [text or integer]: the (sub)menu item(s)
returns the reference or missing value
*)
try
set itemCount to (count menuList) -- needs to be at least {application, menu, item}
if itemCount < 3 then error "menuReference handler: the menu item list contains too few items"
set {appName, menuName} to items 1 thru 2 of menuList
set {menuItem, found} to {last item of menuList, false}
tell application appName to activate
tell application "System Events" -- set up the menu path
set appName to (name of application processes whose frontmost is true) as text -- handle different process names
set menuPath to menu menuName of menu bar item menuName of menu bar 1 of application process appName
if itemCount > 3 then repeat with i from 3 to (itemCount - 1) -- add sub menu items
set menuName to item i of menuList
if class of menuName is integer then set menuName to item menuName of (get name of menu items of menuPath)
set menuPath to menu (menuName as text) of menu item (menuName as text) of menuPath
end repeat
if class of menuItem is not integer then -- the target menu item
repeat with anItem in (get name of menu items of menuPath)
if anItem begins with (menuItem as text) then -- match a partial string (also 'contains', etc)
set {menuItem, found} to {anItem, true}
exit repeat
end if
end repeat
if not found then error "menuReference handler: menu item " & quoted form of menuItem & " not found"
end if
return menu item menuItem of menuPath
end tell
on error errorMessage number errorNumber
log errorMessage
# error errorMessage number errorNumber -- uncomment to pass error up the chain
end try
return missing value
end getMenuReference
to clickMenu at menuItem -- Click a menu item in an application's main menu.
(*
The menuItem can be a reference to the menu item or a list of the menu hierarchy.
parameters: menuItem [reference or list] - see the getMenuReference handler
returns true if successful, false otherwise
*)
try
if class of menuItem is list then -- get a reference
set menuItem to getMenuReference for menuItem
if menuItem is missing value then error "clickMenu handler: the menu item was not found"
end if
tell application "System Events"
# log (get properties of menuItem)
if (enabled of menuItem) then -- filter for desired property
click menuItem
delay 0.25
return true -- success
end if
end tell
on error errorMessage number errorNumber
log errorMessage
# error errorMessage number errorNumber -- uncomment to pass error up the chain
end try
return false -- failure
end clickMenu
In Eclipse E4 (Luna), using the application model to create parts, handlers, commands, handled menu items etc, (these are not created programatically). I have a toolbar. This contains a sub-Menu item called "Filter" that contains another sub-menu of two filters. The two filters are two Handled Menu Items which are set up as "Radio" Buttons.
When I select the appropriate in the UI of my running app from the selection, the Radio button switches just fine to the selected Item. However I would like this selection to update (deselecting one Radio button and selecting the appropriate radio button of the handled menu item) when my ViewPart changes through other UI selection. Currently my ViewPart updates, but the Radio buttons are on the same previous selection through the UI.
Is there a way in which I get access both Handled Menu Item's IDs and set the selection (one to false, the other to true) when the viewer is updated.
Image of design is attached below:
Hierarchy of the application model is as follows:
Thanks in advance,
Marv
You can use the model service to find menu items. Use something like:
#Inject
EModelService modelService;
#Inject
MApplication app;
List<MMenuItem> items = modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_MAIN_MENU);
Once you have the MMenuItem you can call the setSelected(boolean) method to change the selection.
To find a menu item which is in a Part menu use:
modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_PART);
(IN_PART argument instead of IN_MAIN_MENU).
You could also specify the MPart rather than the Application as the first argument to findElements which may speed up the search.
For menus as a child of a Tool Bar Item it appears that the model services cannot find these directly. However you can find the Tool Bar Item and look at the menu yourself:
List<MToolItem> items = modelService.findElements(app, "tool bar item id", MToolItem.class, Collections.emptyList(), EModelService.IN_PART);
MToolItem item = items.get(0);
MMenu menu = item.getMenu();
List<MMenuElement> children = menu.getChildren();
... search menu elements
I solved this by starting with MPart PartID and drilling down to the HandledMenuItems on which I wanted to set the Radio Button selections, then setting the selection property for each individual HandledMenuItem.
This can probably be refactored to be more concise, but I've left the code with each step to have the solution easier to read.
BTW, in every instance / combination of the EModelService methods, the list returned a size of 0. So I'm not certain if that will work for what I'm trying to achieve. The following does work, although I'm not certain it is the most efficient means.
I hope this helps others.
// Get view part
MPart viewPart = _partService.findPart("part_id");
// get list of all menu items from the Part
List<MMenu> viewPartMenu = viewPart.getMenus();
// Get list of ViewMenus from viewPartMenu there is only one View Menu so it will be index 0
MMenu viewMenu = viewPartMenu .get(0);
// Get list of MMenuElements from the viewMenu - the children in the view menu
List<MMenuElement> viewMenuElements = viewMenu.getChildren();
// This gets me to the 2 HandledMenuItems
// Upper Most HandledMenuItem Radio Button is at viewMenuElements index 0. This is cast to MHandledMenuItem
MHandledMenuItem upperHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(0);
// Set Selection
upperHandledMenuItem.setSelected(false);
// Lower Most HandledMenuItem Radio Button is at viewMenuElements index 1. This is cast to MHandledMenuItem
MHandledMenuItem lowerHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(1);
// Set selection
lowerHandledMenuItem.setSelected(true);
In my project, there is a menu that need to be appended an item dynamically.
In original code, items in the menu are stationary. So the menu is defined in the resource file:
IDM_SERVER_OPTIONS MENU DISCARDABLE
BEGIN
POPUP ""
BEGIN
MENUITEM "&Connect", IDC_LAUNCHITEM_CONNECT
MENUITEM "&Delete", IDC_REMOVE_SERVER
END
END
and is loaded in the code:
CMenu menu;
menu.LoadMenu(IDM_SERVER_OPTIONS);
Now, there is a new requirement that need to append a dynamic menu item after load the resource menu. I referred this aricle:
Dynamic menu using mfc
Followed it, I wrote these code:
CMenu menu;
menu.LoadMenu(IDM_SERVER_OPTIONS);
CMenu *autoConnectMenu = new CMenu;
autoConnectMenu->CreatePopupMenu();
autoConnectMenu->AppendMenu(MF_STRING | MF_ENABLED,
IDC_MENU_AUTO_CONNECT_SERVER,
utils::LoadString(IDS_MENU_AUTO_CONNECT_SERVER));
menu.AppendMenu(MF_POPUP,
(UINT)autoConnectMenu->m_hMenu,
L"auto connect server");
Unfortunately, it doesn't work. The new menu item "auto connect server" can't be displayed.
Then, I tried the HMENU function:
CMenu menu;
menu.LoadMenu(IDM_SERVER_OPTIONS);
AppendMenu((HMENU)menu.GetSubMenu(0),
MF_STRING | MF_ENABLED,
IDC_AUTO_CONNECT_SERVER,
utils::LoadString(IDS_MENU_AUTO_CONNECT_SERVER));
It works fine!
I want to know what problem in my former code? Appreciate!
I think that I have found the issue. I should have called
menu.GetSubMenu(0)->AppendMenu(...);
instead of
menu.AppendMenu(...);
I have a big trouble with displaying the left navigation sidebar with product categories.
My category tree looks like
Default category (Is active = Yes, include in navigation menu = Yes, Is anchor = No)
Category (Is active = Yes, include in navigation menu = Yes, Is anchor = Yes)
Category 1 (Is active = Yes, include in navigation menu = Yes, Is anchor = Yes)
Category 2 (Is active = Yes, include in navigation menu = Yes, Is anchor = Yes)
Brand (Is active = Yes, include in navigation menu = Yes, Is anchor = No)
Brand 1 (Is active = Yes, include in navigation menu = Yes, Is anchor = No)
Brand 2 (Is active = Yes, include in navigation menu = Yes, Is anchor = No)
I have products
Product 1 assigned to Category and Category 2.
I have set in System > Manage stores, the Root Category option set to Default Category for all stores.
I didn't make any changes in templates.
Breadcrumbs are correct. I can see the product in Category and Category 2, but if I'm in the Category listing I can't see the subcategories listing, so I can't see the Category 2.
What's the problem here?
When the Category has the Attribute "isAnchor" set to true there wont be a list of subcategories, instead you get the layerednavigation. Set the "isAnchor" to "No" to get a list of subcategories.
How to create a menu dynamically?
In detail I want to:
Create a new ribbon page (tab, I think it's called ribbon page)
Next create a title for the page
Next add 2 ribbon groups and add titles to them
Next add 3 bar button items to the first ribbon group
How to accomplish this?
Dim menu As New RibbonControl
Dim aPage As New RibbonPage("Nicks Page")
'groups
Dim aGroup1 As New RibbonPageGroup("1st Group")
'ADD BUTTONS TO RIBBON GROUP HERE
Dim i As New DevExpress.XtraBars.BarButtonItem()
i.Caption = "Nicks Button"
aGroup1.ItemLinks.Add(i)
Dim i2 As New DevExpress.XtraBars.BarButtonItem()
i2.Caption = "Nicks Other Button"
aGroup1.ItemLinks.Add(i2)
aPage.Groups.Add(aGroup1)
menu.Pages.Add(aPage)
Me.Controls.Add(menu)