Skip to content

Instantly share code, notes, and snippets.

View jacmaes's full-sized avatar

Jacques Maes jacmaes

View GitHub Profile
@jacmaes
jacmaes / this_n_this_and_that.php
Last active December 8, 2020 13:14 — forked from Da-Fecto/this_n_this_and_that.php
this, this, this & that #pw
// In a function:
$count = count($pagearray);
foreach ($pagearray as $key => $p) {
$div = ($key + 1 === $count) ? ($count === 1 ? '' : ' & ') : ($key === 0 ? '' : ', ');
$out .= $div . "<a href='$p->url'>$p->title</a>";
}
echo $out;
// author: http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
<?php
/**
* This module is build by Adrian, tnx Adrian.
*
*
* Module to hide pages that are not editable by the logged in user.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
@jacmaes
jacmaes / from.php
Last active August 29, 2015 14:08 — forked from somatonic/from.php
<?php
// get a page
$editpage = $pages->get("/editme/");
$ignorefields = array("isOld","language_published");
$form = $modules->get("InputfieldForm");
$form->method = 'post';
$form->action = './';
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Enquire Test</title>
<meta name="viewport" content="width=device-width">
<!-- Normalize CSS -->
<link rel="stylesheet" src="http://normalize-css.googlecode.com/svn/trunk/normalize.css"/>
<!-- Bootstrap CSS -->
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
<?php
/**
* collect all tags
* ======================================
*/
$alltags = array(); // container
$use_urlsegments = false;
@jacmaes
jacmaes / search-processor.php
Last active December 6, 2018 14:56 — forked from outflux3/search-processor.php
Search #pw
<?php
// http://processwire.com/talk/topic/1938-building-an-advanced-search-form-with-form-builder/?p=36295
// check if there are GET variables present in the URL
if(count($input->get)) {
$selector = '';
if($input->get->application) {
// http://processwire.com/talk/topic/1938-building-an-advanced-search-form-with-form-builder/?p=36295
<form name='search' id='product-search' method='get' action='<?php echo $config->urls->root?>speaker-finder/'>
<ul id="row1">
<li>
<label for='search_app'>Application</label>
<select id='search_app' name='application' onchange="$(this.form).trigger('submit')">
<option value=''>Any</option><?php
// generate the application options, checking the whitelist to see if any are already selected