Skip to content

Instantly share code, notes, and snippets.

Avatar

Philipp Urlich somatonic

View GitHub Profile
View find matches example
$words = '';
$q = $sanitizer->selectorValue($input->post->q);
$words = explode(' ', $q);
foreach($words as $word) {
$word = $sanitizer->selectorValue($word);
if($word) $selectorEmergencyContacts .= "title|label_$lang*=$word, ";
}
...
View breadcrumbs.php
foreach($page->parents as $p) echo "<a href='$p->url'>$p->title</a>";
View gist:2294810
$parent = '/processwire/access/users/' . $user->name;
foreach($pages->get("/tools/categories/")->children("sort=title") as $tag) {
echo "<h2>$tag->title</h2>";
foreach($pages->find("parent={$parent}, course_categories=$tag") as $p){
echo "<a href='{$p->course_documents->url}'>{$p->course_documents->name}</a>";
}
}
View UserNameLabel.module
<?php
class UserNameLabel extends WireData implements Module{
public static function getModuleInfo() {
return array(
'title' => __('UserNameLabel', __FILE__), // Module Title
'version' => 100,
'summary' => __('Overwrite User Name Label', __FILE__), // Module Summary
'autoload' => true
View gist:2314407
<?php
include($config->paths->root . "site/.libs/countries/countryList.class.php");
$ct = new CountryList();
$countries = $ct->getCountryList($lang);
$show_form = true;
$note = '<h3>Danke!</h3>';
$errors = '';
View test.html
#page>(#header>ul#nav>li*4>a>span.cf)+(#page>(h1>span)+p*2)+#footer
@somatonic
somatonic / body-replacement-video.inc
Created Apr 23, 2012
Replace Youtube URLS with iframe
View body-replacement-video.inc
// replace youtube urls
if(strpos($page->body, '<p>http://www.youtube.com') !== false) {
$replacement = '<iframe width="444" height="280" src="http://www.youtube.com/embed/$1?$2" frameborder="0" allowfullscreen></iframe>';
$page->body = preg_replace('#<p>\s*http://www.youtube.com/watch\?v=([^\s&<]+)([\&amp\;+?].+).*?</p>#iu', $replacement, $page->body);
}
@somatonic
somatonic / index.html
Created Apr 24, 2012
jquery mobile init false
View index.html
$(document).bind("mobileinit", function(){
$.extend( $.mobile , {
autoInitializePage: false,
ajaxEnabled: false,
linkBindingEnabled: false,
pushStateEnabled: false,
hashListeningEnabled: false
});
@somatonic
somatonic / ModuleName.module
Created May 19, 2012
ProcessWire Module Template
View ModuleName.module
<?php
/**
* ProcessWire Module Template
*
* Demonstrates the Module interface and how to add hooks.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
View ProcessDashboard.module
<?php
/*
*
*
*
*/
class ProcessDashboard extends Process {
You can’t perform that action at this time.