Skip to content

Instantly share code, notes, and snippets.

@litzinger
litzinger / gist:8848037
Last active August 29, 2015 13:56
EE - {site_url} vs {path=""} vs relative /
This is a test case based on a discussion with @jacobrussel. He states that all EE sites
should prefix links with a single /, relative to the domain root. I argue that you should
not assume all developers work from the root of a development domain. With MAMP its easy
to setup a vhost, and hard code all your template links such as href="/some/path", but
this completely breaks if someone has to run the site on a server in which they can't
run it at the root of the domain, such as http://dev.server.com/~user/the-site/.
I recommend that links should use {path="some/page"} or more preferablly {site_url}some/page
for maximum portability, but Jacob states that adds extra overhead to parse all the {site_url}
variables. To test this case, I created a blank template in EE, and put in {site_url} 1000 times.
#!/bin/bash
set -o errexit
# Author: David Underhill
# http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
@litzinger
litzinger / ee-route-example.php
Last active August 29, 2015 13:56
How to extend EE's new routes feature in an extension hook.
<?php
public function core_template_route($uri_string)
{
ee()->your_lib_or_model->load_routes();
// Rest of your hook processing, if any.
}
public function load_routes()
@litzinger
litzinger / pill.css
Created June 23, 2014 00:49
Add disabled option to P&T Pill
ul.pt-pill { display: inline-block; margin: 5px 0; padding: 0; list-style-type: none; height: 18px; cursor: default; white-space: nowrap;
-webkit-user-select: none; -moz-user-select: none; }
ul.pt-pill li { float: left; margin: 0 -1px 0 0; padding: 0 7px; border: 1px solid #a8b1b3; line-height: 18px; background: #fff url(../images/option_bg.gif) repeat-x; cursor: pointer; }
ul.pt-pill li:first-child { -webkit-border-top-left-radius: 3px; -webkit-border-bottom-left-radius: 3px; -moz-border-radius: 3px 0 0 3px; }
ul.pt-pill li:last-child { -webkit-border-top-right-radius: 3px; -webkit-border-bottom-right-radius: 3px; -moz-border-radius: 0 3px 3px 0; }
ul.pt-pill li.selected { background: #fff; position: relative; z-index: 1; text-shadow: 0 1px #fff; cursor: default;
background: url(../images/selected_bg.gif) repeat-x;
@litzinger
litzinger / autosave.js
Last active August 29, 2015 14:05
How to add autosave support to 3rd party fieldtype in EE that uses a custom table.
// Add Autosave support
if(typeof EE.publish == "object" && EE.publish.autosave == "object" && EE.publish.autosave.interval > 10)
{
// 3 seconds before the defined interval
interval = (EE.publish.autosave.interval - 3) * 1000;
setInterval({
run: function() {
// Do whatever you need to do here, probably an ajax request, to save data to custom table.
}
@litzinger
litzinger / index.sql
Created August 28, 2014 20:33
Speed up EE entries table requests
ALTER TABLE exp_channel_titles ADD INDEX sdi(sticky, entry_date, entry_id)
(function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
{exp:channel:form channel="pages" return="forms/channel-edit/ENTRY_ID" entry_id="{segment_3}"
include_jquery="yes"
include_assets="yes"
error_handling="inline"
use_live_url="yes"
datepicker="no"}
{field_errors}{error}{/field_errors}
<label for="title">Title</label>
@litzinger
litzinger / puphpet-config.yml
Last active August 29, 2015 14:17
Config Tricks to speed up Symfony in dev mode.
php:
install: '1'
version: '56'
composer: '1'
composer_home: ''
modules:
php:
- cli
- intl
- mcrypt
@litzinger
litzinger / ee-varnish.conf
Created September 3, 2015 14:35
Basic configuration for EE and Varnish
backend default {
# .host = "XXX.XXX.XXX.XXX";
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
# Forward client's IP to backend
remove req.http.X-Forwarded-For;