Skip to content

Instantly share code, notes, and snippets.

Philipp Urlich somatonic

View GitHub Profile
@somatonic
somatonic / form-process.php
Last active May 13, 2020
ProcessWire example front-end form with file upload and fields
View form-process.php
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
@somatonic
somatonic / inputfieldfile-form.php
Last active Feb 13, 2020
ProcessWire front-end upload form example using ProcessWire Inputfields and form processing.
View inputfieldfile-form.php
<?php
/**
* ProcessWire (2.5) InputfieldFile front-end upload form example
* Various workarounds to get it working with Errors for WireUpload
* and removing files upload after error
*/
$sent = false;
$upload_path = $config->uploadTmpDir;
@somatonic
somatonic / repeater_example.php
Last active Nov 23, 2019
example repeater creation and save front-end form
View repeater_example.php
<?php
$mypage = $pages->get("/about/");
if($input->post->submit){
$n = 1;
$title = "element_title_$n";
$url = "external_url_$n";
$mypage->setOutputFormatting(false);
@somatonic
somatonic / form-example.php
Last active Jul 25, 2019
PW simple form via API
View form-example.php
<?php
$out = '';
// create a new form field (also field wrapper)
$form = $modules->get("InputfieldForm");
$form->action = "./";
$form->method = "post";
$form->attr("id+name",'subscribe-form');
@somatonic
somatonic / pw-multilevelnavbar-boostrap.php
Last active Feb 4, 2019
MarkupSimpleNavigation Example for Bootstrap 2.3.2 Multilevel Navbar
View pw-multilevelnavbar-boostrap.php
<?php
/*
MarkupSimpleNavigation Example for Bootstrap 2.3.2 Multilevel Navbar
*/
// load MarkupSimpleNavigation module
$nav = $modules->get("MarkupSimpleNavigation");
@somatonic
somatonic / createTemplatesFields.php
Last active Nov 1, 2018
Create templates and fields using array.
View createTemplatesFields.php
<?php
// .... module
// create fields and templates using arrays
public function getTemplatesConfig() {
// title | field1 | field2 ...
$templatesArray = array(
'category' => array('title'),
@somatonic
somatonic / CustomPageSave.module
Created Apr 23, 2014
add new save button on page edit, to do something additional on save
View CustomPageSave.module
<?php
/**
* Adding other types of save buttons for page edit form.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://www.processwire.com
@somatonic
somatonic / example-filter-form.php
Created Jul 5, 2018
Example filter form with pagination
View example-filter-form.php
<?php namespace ProcessWire;
$filter = "";
$form = $modules->InputfieldForm;
$form->attr("action", $page->url);
$form->attr("method", "get");
// select with sort options
$f = $modules->InputfieldSelect;
@somatonic
somatonic / from.php
Last active Jun 26, 2018
Create a page edit form on frontend using PW API and fields from the template of the page
View from.php
<?php
// get a page
$editpage = $pages->get("/editme/");
$ignorefields = array("isOld","language_published");
$form = $modules->get("InputfieldForm");
$form->method = 'post';
$form->action = './';
@somatonic
somatonic / HiddenAdminPages.module
Last active Jun 18, 2018
Hide page in the admin per user per page/branch
View HiddenAdminPages.module
<?php
/**
* UserWorkspaces
*
* Example module to hide page in the admin per user per page.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
You can’t perform that action at this time.