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 / PageListActionHook.module
Created Mar 11, 2014
PageListActionHook example module to hook into page list actions
View PageListActionHook.module
<?php
/**
* ProcessWire example demonstration module
*
* PageListActionHook autoload module once installed will remove "new" action from second level pages
* using the template "basic-page"
*
*/
@somatonic
somatonic / MyHelper.module
Created Jan 15, 2014
Example helper module that adds a new system variable "$helper" with a method to generate FontAwesome markup for use in templates
View MyHelper.module
<?php
class MyHelper extends WireData implements Module {
/**
* getModuleInfo is a method required by all modules to tell ProcessWire about them
* @return array
*/
public static function getModuleInfo() {
return array(
'title' => 'My Helper Module',
@somatonic
somatonic / mylist.php
Last active Jan 3, 2016
page list select indent
View mylist.php
<?php
$children = $pages->get("/shop/")->children();
$list = new PageArray();
function mylist($children, $ind='', $arr){
$ind .= "";
foreach($children as $cat) {
@somatonic
somatonic / get_field_settings.php
Last active Jan 2, 2016
get field settings via API
View get_field_settings.php
<?php
// via field settings
$field = $fields->get("title");
echo "width:" . $field->columnWidth;
// via template context
$tpl = $templates->get("basic-page");
$field = $tpl->fieldgroup->getField("title", true);
echo "width:" . $field->columnWidth;
@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]);
}
}
View pw_image_rename2.php
<?php
// stripped down code
$old_name = 'lizard.jpg';
$new_name = 'wizard';
$p = $pages->find("image.data=$old_name")->first();
$p->of(false); // outputformatting off, single and multiple image fields are from now on wire array's
@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 / 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 / image_tags.php
Last active Dec 18, 2015
Collect all tags from images field and create a link list to then filter pages with images that have the selected tag
View image_tags.php
<?php
/**
* collect all tags
* ======================================
*/
$alltags = array(); // container
$use_urlsegments = false;
@somatonic
somatonic / ImageCreateThumbs.module
Last active Jan 31, 2017
create thumbs when uploading image
View ImageCreateThumbs.module
<?php
class ImageCreateThumbs extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'ImageCreateThumbs',
'version' => 100,
'summary' => '',
You can’t perform that action at this time.