Skip to content

Instantly share code, notes, and snippets.

View kaspar-allenbach's full-sized avatar

KSPR kaspar-allenbach

View GitHub Profile
@kaspar-allenbach
kaspar-allenbach / SassMeister-input.scss
Last active December 17, 2019 13:05
scss grid offset loop
// ----
// Sass (vundefined)
// Compass (vundefined)
// dart-sass (v1.18.0)
// ----
$gridBaseNumber: 12;
@kaspar-allenbach
kaspar-allenbach / ieDetection.js
Created January 30, 2019 12:44
IE 11 detection + add warning div to body
//check for ie methods
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
//start if ie
if (isIE11 == true) {
//add tags to body to write scoped css
document.body.className += " " + "internetExplorer ie11"
//add div element to warn users that they are using an outdated browser
window.document.body.insertAdjacentHTML( 'afterbegin', '<div class="oldIE">You are using an outdated Browser…</div>' );
}
@kaspar-allenbach
kaspar-allenbach / readme.md
Last active April 10, 2018 10:49
Craft3 deprecated Tags

Craft 3 Learning Curve

I try to create a comprehensive tag list of Old vs new craft tags. SO lets start Craft 3 Changes

  • All loops have to be called with .all()
  • Macros have to be imported in EVERY file they apear. Not just in the parent file 🤬
  • _self macros have to be imported into the parent macro with {% import _self as macro %} SE Querstion

Accessing the settings in general.php

@kaspar-allenbach
kaspar-allenbach / readme.md
Created February 21, 2018 13:56
Craft CMS Language Switcher

Craft CMS Language Switcher

How to?


{% set otherLocales = craft.i18n.getSiteLocaleIds() %}
<li class="languageSwitch">
  {% for locale in otherLocales %}
 {% set localeEntry = craft.entries.id(entry.id).locale(locale).first %}
@kaspar-allenbach
kaspar-allenbach / readme.md
Last active February 21, 2018 08:58
Craft 3 Multilang Setup

In Craft CMS 3 there are some minor adjustements to make when setting up a localized website. The Old Guide to setup a localized Site is still valid with some differences.

File Setup

You have to create a language folder in the public directory with a .htaccess and a index.php

Let's say you want english as a second language with the url extension yourdomain.com/en.

  1. create a folder en.
@kaspar-allenbach
kaspar-allenbach / fout.md
Last active January 31, 2018 13:28
Prevent FOUT
@kaspar-allenbach
kaspar-allenbach / Pagination.twig
Created January 30, 2018 14:08
Craft CMS Pagination
{# Set parameters for prev/next elements list #}
{% set params = craft.entries.section('blogEntry').order('title asc') %}
{# Get the prev/next elements #}
{% set prevEntry = entry.getPrev(params) %}
{% set nextEntry = entry.getNext(params) %}
{# And make sure to only output the links if the element exists #}
<div class="blogPagination">
{% if prevEntry %}
@kaspar-allenbach
kaspar-allenbach / grid.scss
Created January 24, 2018 10:56
GRID CSS Basics
.parentElement {
display: grid; // yeah okay
grid-template-columns: repeat(12, 1fr); // make 12 columns with 1 fraction each
//alt: grid-template-columns: 3fr 1fr 1fr 1fr 3fr; // make a column 3fr wide at the beginning and end (px % vw allowed)
grid-auto-rows: minmax(5vh, auto); // make each row min 5vh in height otherwise apply autogrow
grid-gap: 20px; // add grid
}
.childItem {
grid-column: 2/6; // .childItem runs from axis 2 to axis 6
@include smDown {
@kaspar-allenbach
kaspar-allenbach / hamburgerButton.scss
Last active January 24, 2018 15:27
Hambuerger Toggle Button
@mixin fade($fadeValue: color) {
transition: $fadeValue 0.3s linear;
-webkit-transition: $fadeValue 0.3s linear;
-moz-transition: $fadeValue 0.3s linear;
}
$hamburgerLineSize: 5px;
$hamburgBtnSize: 20px;
.mmenuToggle {
@kaspar-allenbach
kaspar-allenbach / mediaQueries.scss
Last active January 19, 2018 14:33
Mediaquery Queries
// Addaption of https://davidwalsh.name/write-media-queries-sass
$xl-width: '1200px';
$lg-width: '992px';
$md-width: '786px';
$sm-width: '576px';
@mixin xlUp {
@media (min-width: #{$xl-width}) { @content; }
}