Skip to content

Instantly share code, notes, and snippets.

View joshangell's full-sized avatar

Josh Angell joshangell

View GitHub Profile
<?php
namespace Craft;
class EntryTypeSourcesPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('Entry Type Sources');
}
@nedmas
nedmas / gist:1287451
Created October 14, 2011 15:40
Just a simple bash script for adding new sites on an apache server
#!/bin/bash
while getopts ":h:p:a:d:l:" opt; do
case $opt in
h)
HOST="$OPTARG"
;;
p)
PORT="$OPTARG"
;;
@boboldehampsink
boboldehampsink / AssetUploadPlugin.php
Last active December 26, 2015 20:49
Enable this plugin to connect <input type="file" name="fields[yourField]" /> as asset to yourField
<?php
namespace Craft;
class AssetUploadPlugin extends BasePlugin
{
function getName()
{
return Craft::t('Upload assets on the front-end');
}
@kant312
kant312 / extract-translations.php
Last active November 7, 2017 11:21
Script (PHP) to extract all translatable strings from Craft CMS templates located in a specific folder
<?php
/**
* @author Quentin Delcourt <quentin@delcourt.be>
* @date 2017-06-21
*
* This script will take a folder path in argument and will extract
* all translatable strings from the Craft templates encountered
* in the given folder. Each one of these will be
* outputted to stdOut in CSV format.
@lukeholder
lukeholder / nav.twig
Last active June 20, 2018 16:53
nested navigation with in template variables.
{% set nav = [
{"href": "http://1.com", "name": "link1","sublinks":null},
{"href": "http://1.com", "name": "link2","sublinks":null},
{"href": "http://1.com", "name": "link3","sublinks":
[{"href": "http://1.com", "name": "link 3.11","sublinks":null},
{"href": "http://1.com", "name": "link 3.22","sublinks":
[{"href": "http://1.com", "name": "link 3.11","sublinks":null},
{"href": "http://1.com", "name": "link 3.22","sublinks":null}
]
}]
@pamelafox-coursera
pamelafox-coursera / CalendarHelper.class.php
Created April 10, 2013 23:09
Generate iCal files in PHP
<?php
class CalendarEvent {
/**
*
* The event ID
* @var string
*/
private $uid;
@brandonkelly
brandonkelly / gist:8149062
Last active July 30, 2018 08:26
Saving new Matrix data
<?php
// Get the entry
$entry = craft()->entries->getEntryById(100);
// Convert the existing data to what it would look like in POST
$matrixData = array();
foreach ($entry->matrixField as $block)
{
@Chrisedmo
Chrisedmo / Craft3ValetDriver.php
Created February 1, 2017 10:29
Craft 3 Composer Install Valet Driver
<?php
class Craft3ValetDriver extends ValetDriver
/* https://github.com/laravel/valet/blob/master/cli/drivers/CraftValetDriver.php */
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
@ryanscherler
ryanscherler / php-openssl.md
Last active August 16, 2018 20:06
Use Homebrew PHP with OpenSSL instead of SecureTransport
@croxton
croxton / .env.php
Last active March 20, 2019 19:23
Craft 3 live previews across different root (or sub) domains
<?php
// In general.php define an alias:
'aliases' => [
'@baseUrl' => getenv('CRAFTENV_BASE_URL')
],
// In the CP, set the Base URL for each site to @baseUrl/
// When previewing, the CP will therefore always use the hostname the editor logged into as the base url for the preview
// (that happens with 'new' entries anyway regardless of base url, but existing entries use base url).