Skip to content

Instantly share code, notes, and snippets.

Philipp Urlich somatonic

Block or report user

Report or block somatonic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 / repeater_example.php
Last active Apr 11, 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 / 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 / form-process.php
Last active Aug 15, 2018
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 / 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
@somatonic
somatonic / creat_zip_download.php
Last active Mar 6, 2018
create a zip file and send to browser
View creat_zip_download.php
<?php
/* creates a compressed zip file */
function create_zip($files = array(),$destination = '',$overwrite = false) {
if(file_exists($destination) && !$overwrite) { return false; }
if(is_array($files)) {
foreach($files as $name => $file) {
if(!file_exists($file)) unset($files[$name]);
}
}
You can’t perform that action at this time.