Skip to content

Instantly share code, notes, and snippets.

@sidedwards
Last active December 3, 2018 09:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidedwards/89861539d16e8d02cf4bcb388422bf28 to your computer and use it in GitHub Desktop.
Save sidedwards/89861539d16e8d02cf4bcb388422bf28 to your computer and use it in GitHub Desktop.
Hide Sidebar in Craft 3 Control Panel

Hide sidebar in Craft 3 _layouts/cp

Snippet for hiding the sidebar in the Craft 3 control panel for Element index pages.

Since the Craft 3 sidebar handles the index source for querying elements it can be tricky disabling the sidebar and still executing the query.

This uses a twig macro to duplicate the sidebar and hide it while still being able to pass an index source for the query.

See the Craft templates/_layouts/cp.html file for more layout information

{% extends "_layouts/cp" %}
{% set elementType = 'Element' %}
{% import 'macros' as macros %}
{% block content %}
<div class="elementindex">
{{ parent() }}
{{ macros.setElementIndexSource('*') }}
{% include "_elements/indexcontainer" with {
showSiteMenu: true
} %}
</div>
{% endblock %}
{% macro setElementIndexSource(source) %}
<div class="sidebar hidden">
<nav>
<ul>
<li>
<a data-key="{{ source }}"></a>
</li>
</ul>
</nav>
</div>
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment