Skip to content

Instantly share code, notes, and snippets.

View somatonic's full-sized avatar

Philipp Urlich somatonic

View GitHub Profile
@somatonic
somatonic / posts.php
Created March 1, 2013 23:29
This script generates a list of post with a prev next pagination to show posts of a specified day and category through urls segments
<?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
@somatonic
somatonic / prev_next_day_posts.php
Last active December 14, 2015 09:49
example to render today posts with prev day next day links if found . with url segments for category and day date
<?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
@somatonic
somatonic / from.php
Last active June 26, 2018 19:23
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 = './';
@somatonic
somatonic / pw_bootstrap_menu.php
Last active December 12, 2015 08:18
function to render nested Twitter Bootstrap menu markup
<?php
/**
* render markup menu for bootstrap nested navigation
*
* @param PageArray $pa pages of the top level items
* @param Page $root root page optional, if you use other root than home page (id:1)
* @param string $output for returned string collection
* @param integer $level internally used to count levels
* @return string menu html string
@somatonic
somatonic / TextDomainHelper.module
Last active December 11, 2015 00:59
textdomain infos
<?php
class TextDomainHelper extends Wire implements Module {
public static function getModuleInfo() {
return array(
'title' => 'TextDomainHelper',
'version' => 1,
@somatonic
somatonic / MapPageField.module
Created December 19, 2012 08:32
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
@somatonic
somatonic / TextAreaCounter.js
Created December 10, 2012 20:01
TextAreaCounter JScript
(function($){
$(function(){
$('textarea[data-maxlength]').each(function(){
$(this).bind("keyup change", function(){
var count = $(this).attr('data-maxlength') - $(this).val().replace(/\r?\n/g, '\r\n').length;
$(this).parent().find("span.counter span").text(count);
});
});
@somatonic
somatonic / TextAreaCounter.module
Created December 10, 2012 20:00
TextAreaCounter concept module
<?php
// start module to textarea counter
class TextAreaCounter extends WireData implements Module {
//const default_maxlength = 255;
/**
* getModuleInfo is a module required by all modules to tell ProcessWire about them
@somatonic
somatonic / upload_images_to_page_form.php
Created November 26, 2012 22:08
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
@somatonic
somatonic / form-example.php
Last active September 14, 2021 01:46
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');