Parent Accessible if any Children are

33 Views Asked by At

Is there a way to make a parent menu item accessible only if at least one of it's children are accessible?

The below code demonstrates what I'm trying to do:

function foo_menu() {

    $items = array();

    $items['admin/help'] = array(
        ...
        'access callback' => [ANY OF CHILDREN TRUE?],
    );

    $items['admin/help/foo1'] = array(
        ...
        'access callback' => '_foo_access1',
    );

    $items['admin/help/foo2'] = array(
        ...
        'access callback' => '_foo_access2',
    );

    ....

I know I could create an access callback combining all the child access callback... like:

return _foo_access1() || _foo_access2() || ...

but I was wondering if there was a more automatic way to do this... so if more children are added I don't have to do anything extra.

0

There are 0 best solutions below