Skip to content

Instantly share code, notes, and snippets.

<?php
// check if there are GET variables present in the URL
if(count($input->get)) {
$selector = '';
if($input->get->application) {
$application = $sanitizer->pageName($input->get->application);
$appid = $pages->get("template=product-options, name=$application");
@kongondo
kongondo / search-form.php
Created June 7, 2013 08:25 — forked from outflux3/search-form.php
Processwire sample search form based on skyscrapers search http://processwire.com/talk/topic/3671-ohmspeakercom/page-2#entry36929
<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
foreach($pages->get(1016)->children('include=all') as $app) {
$selected = $app->name == $input->whitelist->application ? " selected='selected' " : '';
@kongondo
kongondo / ImageCreateThumbs.module
Created June 7, 2013 09:09 — forked from somatonic/ImageCreateThumbs.module
create thumbs when uploading image
<?php
class ImageCreateThumbs extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'ImageCreateThumbs',
'version' => 100,
'summary' => '',
@kongondo
kongondo / form-example.php
Created June 7, 2013 09:12 — forked from somatonic/form-example.php
PW simple form via API
<?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');
@kongondo
kongondo / from.php
Created June 7, 2013 09:13 — forked from somatonic/from.php
Create a page edit form on frontend using PW API and fields from the template of the page
<?php
// get a page
$editpage = $pages->get("/editme/");
$ignorefields = array("isOld","language_published");
$form = $modules->get("InputfieldForm");
$form->method = 'post';
$form->action = './';
@kongondo
kongondo / upload_images_to_page_form.php
Created June 7, 2013 09:13 — forked from somatonic/upload_images_to_page_form.php
Upload Images to new created Page Form Example
<?php
// front-end form example with multiple images upload
// add new page created on the fly and adding images
$message = '';
if($input->post->submit){
// tmp upload folder for additional security
@kongondo
kongondo / form-process.php
Created June 7, 2013 09:14 — forked from somatonic/form-process.php
ProcessWire example front-end form with file upload and fields
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
@kongondo
kongondo / form.php
Created June 7, 2013 09:15 — forked from somatonic/inputfieldfile-form.php
ProcessWire front-end upload form example using ProcessWire Inputfields and form processing.
<?php
/**
* Front-end upload form example
* using ProcessWire Inputfields
*/
$sent = false;
$upload_path = $config->paths->assets . "files/.tmp_uploads/";
@kongondo
kongondo / form_with_fields_in_table.php
Created June 7, 2013 09:15 — forked from somatonic/form_with_fields_in_table.php
form with fields rendered in a table example
<?php
/**
* Example form using PW API
*
* A workaround to get fields display in a table
* Those fields are marked with a property added to the fields $field->tablerow
*
* Approach is to grab those fields after form is put together and maybe processed,
* loop each row and render out the fields along with possible errors and add it to a string variable $table
* while we remove the field from the form at the same time.
@kongondo
kongondo / HiddenAdminPages.module
Created June 7, 2013 09:16 — forked from somatonic/HiddenAdminPages.module
Hide page in the admin per user per page/branch
<?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