<div class="sidebar">

    <div class="sidebar-search">
        <div class="sidebar-search__input-wrap">
            <i class="fa fa-search sidebar-search__icon"></i>
            <input type="text" class="sidebar-search__input" placeholder="Search menu..." autocomplete="off">
            <button type="button" class="sidebar-search__clear" style="display:none">
                <i class="fa fa-times"></i>
            </button>
        </div>
    </div>

    <ul class="topnav">

        <li class="siteNavigation t" data-section-id="section-site-nav">
            <span class="sectionHeader">
                Site Navigation
                <i class="fa fa-chevron-right sidebar-toggle-icon"></i>
            </span>

            {% if admin_id is not empty and admin_user is not empty %}
                <ul>
                    <li>
                        <a href="/admin/"
                            title="Go to {{ config('app.name') }} Admin home"
                        >
                            <i class="fa fa-home"></i>
                            Dashboard
                        </a>
                    </li>
                    <li>
                        <a href="/"
                            title="Go to {{ config('app.name') }}"
                            target="_blank"
                        >
                            <i class="fa fa-globe"></i>
                            Homepage
                        </a>
                    </li>
                    <li>
                        <a href="/admin/logout.php">
                            <i class="fa fa-sign-out"></i>
                            Logout
                        </a>
                    </li>
                </ul>
            {% endif %}
        </li> <!-- .siteNavigation -->

        {% include('admin/favourite_links.twig') %}


        {% if admin_id is not empty %}
            {% for menu_item in admin_menu %}
                <li data-section-id="section-{{ menu_item.id }}">
                    <span class="sectionHeader">
                        {{ menu_item.title }}
                        <i class="fa fa-chevron-right sidebar-toggle-icon"></i>
                    </span>
                    {% if menu_item.subItems|length > 0 %}
                        <ul class="{% if menu_item.hasActiveChild() %}show{% endif %}">
                            {% for sub_menu_item in menu_item.subItems %}
                                {% if sub_menu_item.allowed() and sub_menu_item.icon and sub_menu_item.sub_id %}
                                    <li class="{% if sub_menu_item.isActive() %}active nav-twig{% endif %}">
                                        <a href="{{ sub_menu_item.path }}"
                                        {% if sub_menu_item.new_window %}
                                            target="_blank"
                                            title="opens in a new window"
                                        {% endif %}>
                                            <i class="{{ sub_menu_item.icon }}"></i>
                                            {{ sub_menu_item.title }}
                                            {% if sub_menu_item.path == '/plugins/MembersMessaging/admin/my_messages.php' %}
                                                ({{ new_message_count }})
                                            {% endif %}
                                        </a>
                                        {{ sub_menu_item.showCMSTreeIfAllowed(admin_user) }}
                                    </li>
                                {% endif %}
                            {% endfor %}
                        </ul>
                    {% endif %}
                </li>
            {% endfor %}
            {% if admin_user.user.role == 7 %}
                <li data-section-id="section-support">
                    <span class="sectionHeader">
                        Support
                        <i class="fa fa-chevron-right sidebar-toggle-icon"></i>
                    </span>
                    <ul>
                        <li>
                            <a href="https://projects.mtcmedia.co.uk" target="_blank">Submit a ticket <i class="fa fa-file"></i></a>
                        </li>
                    </ul>
                </li>
            {% endif %}
        {% else %}
            <li data-section-id="section-login">
                <span class="sectionHeader">
                    Admin Login
                    <i class="fa fa-chevron-right sidebar-toggle-icon"></i>
                </span>
                <ul>
                    <li>
                        <a href="/admin/login.php">Login <i class="fa fa-file"></i></a>
                    </li>
                </ul>
            </li>
        {% endif %}
    </ul>

</div>
