Skip to content

Instantly share code, notes, and snippets.

@carlcs
carlcs / .env
Created September 20, 2018 10:40
Site URLs with multiple sites in Craft 3
SITE_URL_EN="@web"
SITE_URL_DE="@web/de"
@carlcs
carlcs / Module.php
Last active July 27, 2018 14:01
Make asset titles non-translatable
<?php
namespace modules;
use Craft;
use craft\elements\Asset;
use yii\base\Event;
use yii\base\ModelEvent;
class Module extends \yii\base\Module
<?php
namespace modules;
use Craft;
use craft\elements\Entry;
use craft\events\ModelEvent;
use DateTime;
use yii\base\Event;

Apache env variables

Output the PATH env variable:

echo getenv('PATH');
die();

These don’t work with a brew services started httpd:

@carlcs
carlcs / Module.php
Last active February 18, 2019 13:23
<?php
namespace modules;
use Craft;
class Module extends \yii\base\Module
{
/**
* Initializes the module.
{% extends '_layouts/standard' %}
{% set cacheContentBlock = true %}
{% block content %}
{# ...content worth caching #}
{% endblock %}
<?php
namespace Craft;
class BusinessLogicVariable
{
public function getRequestedLocaleId()
{
// Return the current locale ID if any path is requested
if (craft()->request->getUrl() !== '/') {
return craft()->locale->id;
import qs from 'qs';
import Axios from 'axios';
Axios.defaults.baseURL = Craft.baseUrl;
Axios.defaults.headers.common['Accept'] = 'application/json';
Axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Axios.interceptors.request.use(config => {
if (config.data instanceof FormData) {
#!/bin/bash
BASE_PATH="./"
R0=(craft-assetmetadata v2 v3)
R1=(craft-elementstats v1 v2)
R2=(craft-footnotes v1 v2)
R3=(craft-maintenance v2 v3)
for i in {0..10}
do