'Custom Layout Method'

@staticmethod
def layout(item):

    if (not item.authorized):
        item.enabled = False
        item.visible = False
    elif ((item.enabled is None) or item.enabled):
        item.enabled = True
        item.visible = True
    if (item.enabled and item.visible):
        items = item.render_components()
        if (item.parent is not None):
            classes = []
            if (item.parent.parent is None):
                toplevel = True
                if item.opts.right:
                    classes.append('menu-right')
            else:
                toplevel = False
            if item.components:
                classes.append('has-dropdown    not-click')
                if item.selected:
                    classes.append('active')
                _class = '    '.join(classes)
                if item.get_first(enabled=True, link=True):
                    _href = item.url()
                    return LI(A(item.label, _href=_href, _id=item.attr._id), UL(items, _class='dropdown'), _class=_class)
            elif toplevel:
                item_url = item.url()
                if (item_url == URL(c='default', f='index')):
                    classes.append('menu-home')
                if item.selected:
                    classes.append('active')
                _class = '    '.join(classes)
                return LI(A(item.label, _href=item_url, _id=item.attr._id), _class=_class)
            else:
                if isinstance(item.label, dict):
                    if ('name' in item.label):
                        label = item.label['name']
                    else:
                        return None
                else:
                    label = item.label
                link = A(label, _href=item.url(), _id=item.attr._id)
                return LI(link)
        else:
            right = []
            left = []
            for item in items:
                if ('menu-right' in item['_class']):
                    item.remove_class('menu-right')
                    right.append(item)
                else:
                    left.append(item)
            right.reverse()
            if current.response.s3.rtl:
                (right, left) = (left, right)
            T = current.T
            data_options = {'back': T('Back')}
            return NAV(UL(LI(A('    ', _href=URL(c='default', f='index')), _class='name'), LI(A(SPAN(current.T('Menu'))), _class='toggle-topbar    menu-icon'), _class='title-area'), SECTION(UL(right, _class='right'), UL(left, _class='left'), _class='top-bar-section'), _class='top-bar', data={'topbar': '    ', 'options': ('back_text:%(back)s' % data_options)})
    else:
        return None
