Skip to content

Instantly share code, notes, and snippets.

@gebeer
gebeer / index.php
Created October 27, 2014 12:42
Modified index.php for [seb_map template](http://www.seblod.com/products/51) to allow autozoom to map markers
<?php
/**
* @version SEBLOD 3.x More ~ $Id: index.php sebastienheraud $
* @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder)
* @url http://www.seblod.com
* @editor Octopoos - www.octopoos.com
* @copyright Copyright (C) 2013 SEBLOD. All Rights Reserved.
* @license GNU General Public License version 2 or later; see _LICENSE.php
**/
@gebeer
gebeer / breadcrumbs.php
Last active August 29, 2015 14:09
ProcessWire Bootstrap 3 breadcrumbs snippet with microdata
<ol class='breadcrumb' itemprop="breadcrumb">
<?php foreach($page->parents as $parent): ?>
<li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'>
<a href='<?php echo $parent->url; ?>' itemprop='url'>
<span itemprop='title'><?php echo $parent->title; ?></span></a></li>
<?php endforeach ?>
<li class="active"><?php echo $page->title; ?></li>
</ol>
@gebeer
gebeer / bs3AccordionMarkup.php
Created April 6, 2015 04:35
Function to render Bootstrap 3 Accordion markup from a ProcessWire PageArray
/*render a Bootstrap 3 accordion from a PW PageArray
variables passed to this function
$pages: PageArray the children of which will be rendered into an accordion
$title: string, name of the field to be used as panel title, eg "title"
$content: string, name of the field to be used as panel content, eg "bodycopy"
$accordion = "<div class='panel-group' id='accordion' role='tablist' aria-multiselectable='true'>";
*/
function bs3AccordionMarkup($pages, $titlefield, $contentfield) {
$accordion = "<div class='panel-group' id='accordion' role='tablist' aria-multiselectable='true'>";
@gebeer
gebeer / _sticky_footer.scss
Created April 10, 2015 08:15
SASS sticky footer mixin
@gebeer
gebeer / swap-languages.php
Last active November 14, 2015 07:31
PHP function for swapping languages when changing the default language in ProcessWire
<?php
function swapLanguages($pages, $lang) {
$startTime = microtime(true);
$langDefault = "default";
$log = ["languages" => "Swap field values for language {$langDefault} with {$lang}", "pages" =>[]];
$languages = wire("languages");
// get languages
$l1 = $languages->get($langDefault);
@gebeer
gebeer / date-is-in-month.php
Created January 26, 2016 13:45
check if a given date lies within a given month
// example code
// convert the saved date of the page to a timestamp
// $date = strtotime($page->date);
$date = strtotime("12-January-2016");
// convert the $searchdate to a timestamp
$searchdate = strtotime("January-2016") + 1000;
// get first and last timestamp of the given month and year
$getdate = getdate($searchdate);
// get the month number (e.g. 1 for January)
$month = $getdate["mon"];
@gebeer
gebeer / InputfieldLeafletMapMarker.js
Created August 1, 2016 15:59
modified /site/modules/MarkupLeafletMap/InputfieldLeafletMapMarker.js for Processwire. Takes values from custom fields to do the geocoding
/**
* Display a Leaflet Map and pinpoint a location for InputfieldLeafletMapMarker
*
*/
var InputfieldLeafletMapMarker = {
options: {
zoom: 9,
draggable: true,
// Alerts
@include alert-variant($background, $border, $text-color);
// Background Variant
@include bg-variant($parent, $color);
// Border Radius
@include border-top-radius($radius);
@include border-right-radius($radius);
@include border-bottom-radius($radius);
@gebeer
gebeer / summarize-method-hook.php
Last active December 20, 2016 07:41
Text Limiter Hook for ProcessWire - adds a new method summarize() to $page - add this code to site/ready.php
<?
// usage: $page->summaroze($fieldName, $maxLength)
$wire->addHook('Page::summarize', function($event) {
$fieldName = $event->arguments(0);
if(!$fieldName) throw new WireException("No field provided");
// get max length or use 300 as default if none provided
$maxLength = (int) $event->arguments(1);
if(!$maxLength) $maxLength = 300;
@gebeer
gebeer / readme.md
Last active March 29, 2017 06:38
landingpages that live off root ProcessWire