Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Crawford engram-design

View GitHub Profile
View gist:e4133a41613197dfa494d197059a9dfc
<?php
// Turn off all error reporting
error_reporting(0);
$dir = new DirectoryIterator($folder);
$json = array();
foreach ($dir as $index => $fileinfo) {
View _layout.html
<!doctype html>
<html lang="en">
<head>
<!-- Responsive-ness -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- SE-Oh -->
{% include '_includes/seo_meta' %}
</head>
@engram-design
engram-design / data.php
Last active Feb 27, 2017
Property Feed
View data.php
<?php
// Get all XML files in directory
$files = glob('data/*xml');
$jsons = array();
if (isset($_GET['start']) && isset($_GET['end'])) {
$start = $_GET['start'];
$end = $_GET['end'];
View SmartMapPlugin.php
<?php
namespace Craft;
class SmartMapPlugin extends BasePlugin
{
public function init()
{
Craft::import('plugins.smartmap.integrations.feedme.fields.SmartMap_AddressFeedMeFieldType');
}
@engram-design
engram-design / index.twig
Created Oct 8, 2016
Macro to prevent upscaling - something Craft doesn't support just yet...
View index.twig
{# Usage #}
{% set transform = { width: 700, height: 247, mode: 'crop' } %}
<img class="banner" src="{{ _self.transform(entry.bannerImage.first, transform) }}">
{# Macro to prevent upscaling - something Craft doesn't support just yet... #}
{% macro transform(image, transform) %}
{% spaceless %}
{% set originalWidth = image.getWidth(false) %}
{% set transformedWidth = image.getWidth(transform) %}
@engram-design
engram-design / export.php
Last active Oct 29, 2020
ExpressionEngine PHP Export into JSON
View export.php
<?php
$channel = $_GET['id'];
$content = array();
$fields_query = $this->EE->db->query("SELECT * FROM exp_channel_fields LEFT JOIN exp_channels ON exp_channel_fields.group_id = exp_channels.field_group WHERE exp_channels.channel_id = '$channel'");
$entries_query = $this->EE->db->query("SELECT * FROM exp_channel_data cd INNER JOIN exp_channel_titles ct ON cd.entry_id = ct.entry_id WHERE cd.channel_id = '$channel'");
$fields = $fields_query->result_array();
@engram-design
engram-design / en.php
Created Sep 25, 2016
Workflow static translation
View en.php
<?php
return array(
"Workflow" => "Workflow",
"Entry submitted for approval." => "Entry submitted for approval.",
"Could not submit for approval." => "Could not submit for approval.",
"Submission revoked." => "Submission revoked.",
"Could not revoke submission." => "Could not revoke submission.",
"Entry approved and published." => "Entry approved and published.",
@engram-design
engram-design / FeedMeCustomSortPlugin.php
Created Jul 5, 2016
Custom sorting using `postForFeedMeFieldType` with Feed Me
View FeedMeCustomSortPlugin.php
<?php
namespace Craft;
class FeedMeCustomSortPlugin extends BasePlugin
{
// =========================================================================
// PLUGIN INFO
// =========================================================================
public function getName()
View CustomUserDomainPlugin.php
<?php
namespace Craft;
class CustomUserDomainPlugin extends BasePlugin
{
/* --------------------------------------------------------------
* PLUGIN INFO
* ------------------------------------------------------------ */
public function getName()
@engram-design
engram-design / MyPluginNamePlugin.php
Last active Aug 29, 2015
Swap Structures and Channels
View MyPluginNamePlugin.php
<?php
namespace Craft;
class MyPluginNamePlugin extends BasePlugin
{
/* --------------------------------------------------------------
* PLUGIN INFO
* ------------------------------------------------------------ */
public function getName()