Skip to content

Instantly share code, notes, and snippets.

View Da-Fecto's full-sized avatar

Martijn Geerts Da-Fecto

View GitHub Profile
@Da-Fecto
Da-Fecto / JqueryWireTabs.js
Last active December 21, 2015 17:59
JqueryWireTabs.js
/**
* Wire Tabs, jQuery plugin
*
* Developed by Ryan Cramer for ProcessWire
*
*/
(function($) {
$.fn.WireTabs = function(customOptions) {
@Da-Fecto
Da-Fecto / ConditionalDemo.module
Created August 29, 2013 21:03
Put users with the selected role in demo mode.
<?php
/**
* Conditional Demo for ProcessWire
*
* author: Martijn Geerts
* 30 august 2013
*
* ProcessWire 2.x
* Copyright (C) 2012 by Ryan Cramer
@Da-Fecto
Da-Fecto / clean-files.php
Created September 8, 2013 13:12
Clean orphaned files processwire. code from Ryan Cramer
<pre><?php
ini_set('max_execution_time', 60*5); // 5 minutes, increase as needed
include("./index.php");
$dir = new DirectoryIterator(wire('config')->paths->files);
foreach($dir as $file) {
if($file->isDot() || !$file->isDir()) continue;
$id = $file->getFilename();
if(!ctype_digit("$id")) continue;
$page = wire('pages')->get((int) $id);
@Da-Fecto
Da-Fecto / RepeaterTable.module
Last active December 22, 2015 15:38
create table from repeater
<?php
class RepeaterTable extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'RepeaterTable',
'version' => 100,
'summary' => 'RepeaterTable',
'singular' => false,
@Da-Fecto
Da-Fecto / pageimage.php
Last active December 23, 2015 00:28
This is a PW template. Pages using this template are actual images. The advantage of using this approach is a query-able image where you can store meta data & do some GD modifications. Don't forget to enable template caching with this template. Pages using this template should not end with a slash. Pages using this template should end with jpg g…
<?php
// text to print on Image
$text = $page->title;
$image = $page->image->first()->httpUrl;
$info = getimagesize($image);
$type = $info['mime'];
switch ($type) {
@Da-Fecto
Da-Fecto / ImageFitBoundaries.module
Last active December 31, 2015 04:28
Module to caculate max imagesize it could take in a box.
<?php
/**
* ProcessWire 'Image Fit Boundaries' module
*
* Module to calculate the max size a image can take in a boundary box.
* © Martijn Geerts 2013
*
* Usage:
*
@Da-Fecto
Da-Fecto / this_n_this_and_that.php
Last active January 28, 2016 10:14
this, this, this & that
$count = count($pagearray);
foreach ($pagearray as $key => $p) {
$div = ($key + 1 === $count) ? ($count === 1 ? '' : ' & ') : ($key === 0 ? '' : ', ');
$out .= $div . "<a href='$p->url' class=''>$p->title</a>";
}
echo $out;
@Da-Fecto
Da-Fecto / FieldtypeFolder.module
Last active January 1, 2016 09:49
ProcessWire files in folder Fieldtype & Inputfield.
<?php
/**
* ProcessWire files in folder Fieldtype
*
* ©2013 Martijn Geerts
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
@Da-Fecto
Da-Fecto / TextformatterEmail.module
Last active August 29, 2015 13:56
Emailaddress to mailto link
<?php
/**
* ProcessWire Emailaddress mailto link
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://www.processwire.com
@Da-Fecto
Da-Fecto / clear_errors.php
Last active August 29, 2015 14:01
clear error ProcessWire
<?php
wire()->addHookAfter('InputfieldForm::processInput', function($event) {
$form = $event->object;
if($form->name != 'your-form-name') return;
$email = $form->getChildByName('email');
if($email) foreach($f->getErrors(true) as $error) { // true clears existing errors
if($error == 'Missing required value') {
$f->error('Please enter a valid email address'); // replace error message