How to remove the edit option (small gear) on top of widgets?

Hi all!

I'm developing some widgets for informative purposes, which does not need the "edit" function. I've removed the edit.php function from the widget, read through the source code, and found in /vendor/elgg/elgg/engine/lib/navigation.php the following snippet:

        if ($show_edit) {
            $edit = array(
                'name' => 'settings',
                'text' => elgg_view_icon('settings-alt'),
                'title' => elgg_echo('widget:edit'),
                'href' => "#widget-edit-$widget->guid",
                'link_class' => "elgg-widget-edit-button",
                'rel' => 'toggle',
                'priority' => 800,
            $return[] = \ElggMenuItem::factory($edit);

The actual problem is that I still don't know how to declare my widget as "non-editable". I'm declaring it as:

elgg_register_widget_type('mywidget', mywidgetName, mywidgetDescription);

Other than that, is working excellent ;-)

Thanks in advance!!!


  • The menu items are controlled by the 'widget' menu. In the menu hook you can unset the edit link if it's your widget.

    Menu hook reading material

    You get the widget in $params['entity'] and you can check $widget->handler === 'mywidget' for your widget

  • Or use Widget Manager ( to control the widget options, but that is on a per site basis and can't be used programmatically

  • Hi Jerome:

    I wasn't able to do it the way you suggest me, because the menu items were empty when I retrieved them, but your suggestion was very useful for the final solution:

    Just for the record, I was able to do it in the view:

    - Created in my plugin the structure: /views/default/object/widget, and copied header.php from the core.
    - Included after the first "if" block, the following sentences:

    if ($widget->handler === "mywidgetname") {
    $show_edit = false;
    else {
    $show_edit = $widget->canEdit();

    Then in the creation of the $controls, changed 'show_edit' => $widget->canEdit() with 'show_edit' => $show_edit

    This way, I was able to remove the settings' small gear from the header of my widgets.

    Thanks again!