Skip to content

Instantly share code, notes, and snippets.

@kongondo
kongondo / RandomImages.module
Created June 7, 2013 09:16 — forked from somatonic/RandomImages.module
get random images across pages optimized
<?php
/**
* Example use:
*
* $helper = $modules->get("RandomImages");
* $image = $helper->getRandomImages(1,"images");
* echo "<img src='{$image->size(150,0)->url}'>";
*/
@kongondo
kongondo / form-builder-html5off.php
Created June 7, 2013 09:16 — forked from somatonic/form-builder-html5off.php
turn off html5 validation in form builder
<?php
// in form-builder.inc
$forms->addHookBefore('FormBuilderProcessor::render', null, 'hookRenderForm');
function hookRenderForm(HookEvent $event) {
$processor = $event->object;
$form = $processor->getInputfieldsForm();
$form->attr('novalidate', '1');
}
@kongondo
kongondo / paginator.php
Last active December 18, 2015 04:48 — forked from somatonic/paginator.php
manual pagination example for in memory page arrays
<?php
/**
* include paginator class from ProcessWire core, $config->paths->Modulename can
* be used to get the path of any module in PW.
*/
require_once($config->paths->MarkupPagerNav . "PagerNav.php");
/**
@kongondo
kongondo / repeater_example.php
Created June 7, 2013 09:17 — forked from somatonic/repeater_example.php
example repeater creation and save front-end form
<?php
$mypage = $pages->get("/about/");
if($input->post->submit){
$n = 1;
$title = "element_title_$n";
$url = "external_url_$n";
$mypage->setOutputFormatting(false);
@kongondo
kongondo / AddPageFieldProperty.module
Created June 7, 2013 09:18 — forked from somatonic/AddPageFieldProperty.module
add page field as property to page example
<?php
/**
* ProcessWire AddPageFieldProperty demonstration module
*
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
@kongondo
kongondo / MapPageField.module
Created June 7, 2013 09:18 — forked from somatonic/MapPageField.module
maps two page fields POC
<?php
class MapPageField extends WireData implements Module{
public static function getModuleInfo(){
return array(
'title' => 'MapPageField',
'version' => 100,
'singular' => true,
'autoload' => true
@kongondo
kongondo / find matches example
Created June 7, 2013 09:20 — forked from somatonic/find matches example
PW search and find matches
$words = '';
$q = $sanitizer->selectorValue($input->post->q);
$words = explode(' ', $q);
foreach($words as $word) {
$word = $sanitizer->selectorValue($word);
if($word) $selectorEmergencyContacts .= "title|label_$lang*=$word, ";
}
...
@kongondo
kongondo / breadcrumbs.php
Created June 7, 2013 09:21 — forked from somatonic/breadcrumbs.php
PW breadcrumb code
foreach($page->parents as $p) echo "<a href='$p->url'>$p->title</a>";
@kongondo
kongondo / ModuleName.module
Created June 7, 2013 09:21 — forked from somatonic/ModuleName.module
ProcessWire Module Template. It demonstrates the Module interface and how hooks are added
<?php
/**
* ProcessWire Module Template
*
* Demonstrates the Module interface and how to add hooks.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
<?php
/*
*
*
*
*/
class ProcessDashboard extends Process {