Skip to content

Instantly share code, notes, and snippets.

@mr-fan
mr-fan / calfunc.php
Created August 26, 2015 18:58
calendar function recurring events
$event_date = "2012-10-06";
$event_end_date = "2012-10-08";
$event_repetition_type = "Daily";
$date_calculation = "";
switch ($event_repetition_type) {
case "Daily":
$date_calculation = " +1 day";
break;
case "Weekly":
@mr-fan
mr-fan / unzip
Created May 22, 2014 13:38
Unzip on Server - Serv you time!
<?php
$file = 'name_of_the_file.zip';
$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
$zip->extractTo($path);
$zip->close();
echo "$file extracted to $path";
} else {
<?php
// via field settings
$field = $fields->get("title");
echo "width:" . $field->columnWidth;
// via template context
$tpl = $templates->get("basic-page");
$field = $tpl->fieldgroup->getField("title", true);
echo "width:" . $field->columnWidth;
<?php
$children = $pages->get("/shop/")->children();
$list = new PageArray();
function mylist($children, $ind='', $arr){
$ind .= "– ";
foreach($children as $cat) {
<?php
/**
* collect all tags
* ======================================
*/
$alltags = array(); // container
$use_urlsegments = false;
<?php
/**
* Example use:
*
* $helper = $modules->get("RandomImages");
* $image = $helper->getRandomImages(1,"images");
* echo "<img src='{$image->size(150,0)->url}'>";
*/
<?php
/**
* Front-end upload form example
* using ProcessWire Inputfields
*/
$sent = false;
$upload_path = $config->paths->assets . "files/.tmp_uploads/";
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
<?php
// include("./head.inc");
/**
* Script Example
*
* This script generates a prev next pagination to show posts per day of a specified date
* The category is set by the first url segment the date in the second
<?php
/*
* as per http://processwire.com/talk/topic/2928-pagination-by-date/
* list posts by day, show prev next day if any posts found
*
* - posts have a date field "publish_from"
* with no time selection but only days
* this will save the timestamp of today 00:00 (starting) so we can simply
* use "publish_from=$prevday" in selectors