Skip to content

Instantly share code, notes, and snippets.

View low's full-sized avatar
🤖
Multi-tasking

Lodewijk Schutte low

🤖
Multi-tasking
View GitHub Profile
@low
low / ee_clean-install.sql
Created April 16, 2009 08:14
Cleans up a new ExpressionEngine installation
# get rid of template groups
TRUNCATE TABLE exp_template_groups;
INSERT INTO exp_template_groups
(group_name, group_order, is_site_default)
VALUES
('home', '1', 'y');
# get rid of templates
TRUNCATE TABLE exp_templates;
INSERT INTO exp_templates
// To serialize:
// Yeah, that's 3, 1, 3 and 11 backslashes.
preg_replace('/\\\("|\'|\\\)/', '\\\\\\\\\\\$1', serialize($array));
// To unserialize:
$REGX->array_stripslashes(unserialize($string));
@low
low / EE2 Notice
Created May 22, 2010 11:58
Sets default EE notice and closes it after 2 seconds
function _ee_notice($msg)
{
$this->EE->javascript->output(array(
'$.ee_notice("'.$this->EE->lang->line($msg).'",{type:"success",open:true});',
'window.setTimeout(function(){$.ee_notice.destroy()}, 2000);'
));
}
if ( ! empty($errors) )
{
$msg = array();
foreach ($errors AS $line)
{
$msg[] = $this->EE->lang->line($line);
}
$this->EE->session->set_flashdata('errors', $msg);
<?php
/**
* Create files for all templates (EE1)
* Add this to a script somewhere
*/
include PATH_CP.'cp.templates.php';
$CPTMPL = new Templates;
@low
low / gist:1391783
Created November 24, 2011 16:49
Simple EE conditionals turning advanced -- an example
// This will execute the exp:tag if first segment is empty
{if segment_1 != ''}
{exp:class:method}
{if var == "foo"}
Lorem
{if:else}
Ipsum
{/if}
{/exp:class:method}
@low
low / low-reorder-1-docs.html
Created June 5, 2012 14:20
Low Reorder 1 documentation
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="utf-8" />
<meta name="author" content="Lodewijk Schutte | Low" />
<meta name="description" content="go to Low, for Expressionengine Add-ons" />
<title>Low Reorder 1 Documentation</title>
@low
low / gist:3689381
Created September 10, 2012 07:14
Avoid using a tag as parameter value for another tag

Avoid using a tag as parameter value for another tag in ExpressionEngine

Instead of this:

{exp:channel:entries param="{exp:some:plugin}"}
	...
{/exp:channel:entries}

Either use an embed, like this:

@low
low / low-search-ajax.js
Last active October 18, 2020 13:21
Using Low Search for ExpressionEngine with Ajax. Change any of the three variables on top to suit your needs. Tested with jQuery 1.9.0.
(function($){
$(function(){
var $form = $('#search'), // Search form
$target = $('#results'), // Results container
rp = 'search/ajax-results'; // Template for results only
// Function to execute on success
var success = function(data, status, xhr) {
$target.html(data);
};
@low
low / gist:9665729
Created March 20, 2014 14:59
Add LV support to an EE fieldtype, the most basic way: add this to a fieldtype class.
function display_var_field($data)
{
return $this->_display_field("var[{$this->var_id}]", $data);
}