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 / 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 / SiteHelpers.module
Last active Oct 21, 2015
Example page permission hooks. Lister selector hooks
View SiteHelpers.module
<?php
/**
* Site Helpers
*
*
*/
@somatonic
somatonic / HelperHooks.module
Last active Oct 8, 2015
hook to track changes on save ready
View HelperHooks.module
<?php
/**
* Helper Module
* Example to track a change before page is saved
*
*/
@somatonic
somatonic / login.php
Created Jun 8, 2015
processwire login
View login.php
/**
* Custom login
* ==============================================================================
*/
wire()->addHookBefore("ProcessLogin::execute", function($event){
if(wire("user")->isLoggedin() && wire("input")->get("login")) {
wire("session")->redirect("/");
}
});
@somatonic
somatonic / AddImagesFromUrl.module
Last active Aug 29, 2015
AddImagesFromUrl.module
View AddImagesFromUrl.module
<?php
/**
* AddImagesFromUrl
*
* On a page with fields
* "add_images_url" text field
* "images" images field
*
* This basic example module will add the image from the url to the images field on page save.
@somatonic
somatonic / MyPageTableHooks.module
Last active Aug 29, 2015
Example InptfieldPageTable hook module to remove "Add New" button on a condition
View MyPageTableHooks.module
<?php
/**
* Example Hooks to hack InputfieldPageTable to not render add buttons on a condition
* This will remove "add new" buttons if there's more than 2 entries
*
* - First addHookBefore InputfieldPageTable::render to count the value (table rows)
* - If value is greater than 1, we hadd another hook to InputfieldButton::render (used by page table for the buttons)
* and overwrite it with an empty string.
* - Add another hook after page table render to remove the button hooks, to not remove any other buttons rendered
@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 / TextareaStripNbsp.module
Created Apr 9, 2014
Fix TinyMCE &nbsp chars, leaving those without a space in front intact
View TextareaStripNbsp.module
<?php
/**
* TinyMCE replace nbsp with regular whitespace
*
* Only nbsp preceeded with a whitespace will get replaced, this leaves
* single non breaking space only bewtween words
*
* ProcessWire 2.x
* Copyright (C) 2012 by Ryan Cramer
@somatonic
somatonic / HelperFieldsLanguageLabel.module
Created Mar 13, 2014
Adds a method to get lanugage label from a field with $fields->getLangLabel("body")
View HelperFieldsLanguageLabel.module
<?php
/**
* ProcessWire module
*
* Example Fields Language Label Helper
* Gets the language value of a field label for the current user's language
*
* Once Installed it will add a new method to fields
*
@somatonic
somatonic / PageAddableHook.module
Last active Aug 29, 2015
Example module to modify/remove page "addable" permission for pages with level greater than one and basic-page template
View PageAddableHook.module
<?php
/**
* ProcessWire example demonstration module
*
* Page::addable hook module, once installed will set permission "addable" to false
* for pages using basic-page template and with level greater than 1
*/
class PageAddableHook extends WireData implements Module, ConfigurableModule {
You can’t perform that action at this time.