Skip to content

Instantly share code, notes, and snippets.

@sidedwards
sidedwards / description.md
Last active December 3, 2018 09:31
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

@aelvan
aelvan / macro.twig
Created September 23, 2015 15:07
Twig macro for creating a srcset string in Craft
{% macro getSrcSet(image, sizes, upscale) %}
{%- spaceless %}
{% set sizesOut = [] %}
{% set allowScaleLarger = upscale | default(false) %}
{# loop over sizes parameter and generate transforms #}
{% for size in sizes %}
{%- spaceless %}
{% set currentTransform = {} %}
@joshangell
joshangell / go-craft-go.sh
Last active January 26, 2021 00:48
Sets up a new Craft project in the ~/Sites folder with a bunch of plugins and boilerplate. Geared towards OSX users.
#!/bin/sh
printf "\e[34mEnter name for this site\e[0m\n"
read DOMAIN
if [ -z "$DOMAIN" ];
then
DOMAIN="${PWD##*/}"
fi
@johndwells
johndwells / AssetTableModsPlugin.php
Last active June 12, 2017 05:28
Simple plugin to modify the asset's table view in Craft CMS
<?php
namespace Craft;
class AssetTableModsPlugin extends BasePlugin
{
public function getName()
{
return 'Asset Table Modifications';
}