Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Does a product order.
*
* @param string $name
* @param int $quantity
* @return bool
*/
public function doProductOrder($name, $quantity)
{% set bread = craft.entries({ section: 'bread' }).limit(null) %}
{#
# Users with bread on 3 days
#}
{% set users3Days = craft.users({
group: 'customers',
relatedTo: [
'and',
{ targetElement: bread, field: 'breadForMonday' },
<?php
namespace Craft;
class BusinessLogicPlugin extends BasePlugin
{
public function getName()
{
return 'Business Logic';
}

Footnotes plugin - new syntax

Redactor Settings

Add "footnotes" to the "plugins" setting.

"plugins": ["footnotes"],

Footnotes plugin 2.0.0-beta.5

Redactor Settings

Add "footnote" to the "plugins" setting. You can optionally define the button's position in the toolbar with the "footnoteAddAfter" setting.

"plugins": ["footnote"],
"footnoteAddAfter": "lists",
#!/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
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) {
<?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;
{% extends '_layouts/standard' %}
{% set cacheContentBlock = true %}
{% block content %}
{# ...content worth caching #}
{% endblock %}
@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.