Skip to content

Instantly share code, notes, and snippets.

View Natetronn's full-sized avatar

Nathan Doyle Natetronn

View GitHub Profile
@Natetronn
Natetronn / ee-edit-link.html
Last active January 4, 2016 21:19
Edit Entry - ExpressionEngine

Templating in EE vs. Craft

Lots of people have asked, so here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft.

Table of Contents

  1. Comments
  2. Conditionals
  3. Loops
@Natetronn
Natetronn / sha1-passwords.php
Created August 9, 2013 19:05
Generate SHA1 hashes for passwords (don't leave this lying around on your live server of course!)
<?php
$passwords = array(
'somepassword',
'anotherpassword',
'onemorepassword'
// so on and so forth (don't forget the trailing commas)
);
// convert passwords to SHA1 hashes
$this->EE->load->driver('channel_data');
$entries = $this->EE->channel_data->get_channel_entries($channel_id);
foreach($entries->row() as $row)
{
$member = $this->EE->channel_data->get_member_entries($row->author_id);
$data_map = array(
'landscapes_1' => array(
<?php
// Look for this in mod.channel.php (around line 2635):
case 'custom_field' :
if (strpos($corder[$key], '|') !== FALSE)
{
$end .= "CONCAT(wd.field_id_".implode(", wd.field_id_", explode('|', $corder[$key])).")";
}
else
{
@Natetronn
Natetronn / safecracker-garbage-collection.md
Last active April 15, 2019 19:01
Safecracker Garbage Collection

Ever run into this error before?

Uncaught TypeError: Object [object Object] has no method 'markItUp'

If you've ever used Safecracker for ExpressionEngine chances are you have!

What's happening is Safecracker is including JavaScript for custom fields in your form for you. These custom fields rely on said js to function properly. This in itself isn't a big deal but, the issue arises because Safecracker spits out this js right smack in the middle of your template wherever your Safecracker form happens to be located.

Again not the biggest issue except:

@Natetronn
Natetronn / windows-upload-issue.html
Created February 19, 2013 01:58
Windows upload issue
$slash_type = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\\' : '/';
$env_config['upload_preferences'] = array(
1 => array(
'name' => 'Thumbnails',
'server_path' => $images_path . $slash_type. 'uploads' . $slash_type . 'thumbnails/',
'url' => $images_url . '/uploads/thumbnails/'
),
);
@Natetronn
Natetronn / InputfieldTextarea.module
Created January 17, 2013 08:28
ProcessWire InputfieldTextarea.module w/ placeholder text
<?php
/**
* An Inputfield for handling XHTML "textarea" form inputs
*
*/
class InputfieldTextarea extends Inputfield {
const defaultRows = 5;
@Natetronn
Natetronn / config.php
Created October 28, 2012 20:09 — forked from 1stevengrant/config.php
Fixes the daylight savings issue with EE
var $dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('America/New_york'));
$dateTime->setTimestamp(time());
$isDst = (bool)$dateTime->format('I') ? "y" : "n";
$conf['daylight_savings'] = $isDst;
@Natetronn
Natetronn / gist:3716607
Created September 13, 2012 18:45
Matrix naming conventions
{gallery_matrix_images}
<figure>
<img src="{mx_file_src}" alt="{mx_text_alt_tag}" />
<figcaption>{mx_textarea_caption}</figcaption>
</figure>
{/gallery_matrix_images}