Skip to content

Instantly share code, notes, and snippets.

@jpeacock
jpeacock / CustomExporter.php
Last active September 30, 2021 16:32
Craft CMS custom exporter without going to the trouble of making a full plugin or module
<?php
namespace modules;
use Craft;
use craft\base\Element;
use craft\elements\Entry;
use craft\events\RegisterElementExportersEvent;
use yii\base\Event;
use craft\base\EagerLoadingFieldInterface;
@jpeacock
jpeacock / haxor.twig
Created May 17, 2020 15:36 — forked from samhernandez/haxor.twig
Craft 3 gain access to admin account for support cases or when owner loses access
{#
Resets the username, password, and email address
of the first found Admin account in case of
lost admin access or for support cases.
#}
{% set values = {
username: 'me',
password: craft.app.security.hashPassword('mypassword'),
email: '[email protected]'
} %}
@jpeacock
jpeacock / gist:8007520
Last active December 31, 2015 15:29
This is a gist using Expression Engine with Stash. The goal was to get a list of "top" authors based on their post activity. It lists and sorts members by the amount of entries that they have created. It was used to get a "top 10" authors. Also, it's very resource intensive if you have a lot of authors and if you don't cache the query or resulti…
{exp:stash:set_list name="all_entries" parse_tags="yes" output="no" save="yes" refresh="200"}
{exp:channel:entries channel="checkins" dynamic="no" limit="999" orderby="member_id" disable="categories|pagination|custom_fields|category_fields"}
{stash:item_author_id}{author_id}{/stash:item_author_id}
{stash:item_author}{author}{/stash:item_author}
{/exp:channel:entries}
{/exp:stash:set_list}
{exp:stash:set_list name="all_sorted_entries" parse_tags="yes" output="no" parse_conditionals="yes" save="yes" refresh="200"}
{exp:stash:get_list name="all_entries" orderby="item_author_id" sort="asc"}
{stash:eitem_author_id}{item_author_id}{/stash:eitem_author_id}