Skip to content

Instantly share code, notes, and snippets.

View michtio's full-sized avatar
🏠
Working from home

Michael Thomas michtio

🏠
Working from home
View GitHub Profile
<?php
namespace modules;
use Craft;
use craft\controllers\EntriesController;
use craft\controllers\UsersController;
use yii\base\ActionEvent;
use yii\base\Event;
use yii\base\Module;
use yii\web\ForbiddenHttpException;
@unstoppablecarl
unstoppablecarl / how-i-use-vuex.js
Last active June 17, 2020 14:59
How I use vuex
// within a vue component only use mapGetters, mapActions, or this.$store.dispatch(...)
// never directly reference state or mutations from within a vue component
// clearly shows what state data should be exposed and should be internal
import Vue from 'vue'
import Record from '...'
import api from '...'
const store = {
state: {
foo: true,
Some notes here~
{% if relatedArticlesSelect | length == 3 %}
{% set relatedArticles = entry.relatedArticlesSelect.limit(3).all() %}
is the same as
{% set relatedArticlesSelect = entry.relatedArticlesSelect.all() %}
if you know there are only going to be three elements. dot all will fetch all of the elements attached
{% if article is defined %}
<li>
{{article.id}} - {{article.title}}
</li>
{% endif %}
{# Bad: Messy and Hard to Follow #}
{% if link %}
<a href="/recipes/cookies">
{% endif %}
<span>Cookies</span>
{% if link %}
</a>
{% endif %}
{# Good: Clean & Clear #}
@jakedohm
jakedohm / LoginForm.vue
Last active March 22, 2019 22:57
A Vue component to handle submitting login details with Axios, instead of with a standard HTML form
<template>
<form method="post" accept-charset="UTF-8">
<label for="loginName">Username or email</label>
<input v-model="loginName" id="loginName" type="text" name="loginName" />
<label for="password">Password</label>
<input v-model="password" id="password" type="password" name="password" />
<label>
<input v-model="rememberMe" type="checkbox" name="rememberMe" />
<?php
// Element API endpoint
'news.json' => function() {
return [
'elementType' => Entry::class,
'criteria' => [
'section' => 'news'
'join' => [
[
'LEFT JOIN',
- pipeline: "Build and deploy to [environment]"
trigger_mode: "MANUAL"
ref_name: "develop"
actions:
- action: "Init Atomic Deployment"
type: "SSH_COMMAND"
working_directory: "${remote_path}/"
login: "${user}"
host: "${host}"
port: "22"
@bgarrant
bgarrant / Multi-level Bootstrap 4 Navbar With Craft 3 (No Plugins).md
Last active July 30, 2019 08:11
Multi-level Bootstrap 4 Navbar With Craft 3 (No Plugins)

Multi-level Bootstrap 4 Navbar With Craft 3 (No Plugins)

You want to setup a Bootstrap 4 Navbar and use native functions in Craft 3 to manage the navigation menu.

This was built for Bootstrap v4.0 and Craft CMS 3.0.0-RC9

Step 1: Install Craft 3

Go to https://github.com/craftcms/docs/blob/v3/en/installation.md and install Craft 3.

Step 2: Download and Install latest Bootstrap 4 build

@khalwat
khalwat / set-project-perms.sh
Last active January 1, 2020 01:10
Properly set permissions for a Craft CMS install, including ensuring that files are all g-x. Set CHOWN_USER, CHOWN_GROUP, and BASE_DIR to whatever is appropriate, add directories that need to be writeable by the web server to DIRS[], then execute: sudo ./set-project-perms.sh PROJECT_NAME
This is now part of craft-scripts:
https://github.com/nystudio107/craft-scripts