Skip to content

Instantly share code, notes, and snippets.

@gebeer
gebeer / bs3CarouselMarkup
Last active April 14, 2017 08:18
Function to render Bootstrap 3 carousel markup from ProcessWire images object
// renders markup for a Bootstrap 3 Carousel from a ProcessWire images array
function bsCarouselMarkup($images) {
$carouselId = $images->get('page').$images->get('field')->id;
$carouselMarkup = "<div id='carousel-$carouselId' class='carousel slide' data-ride='carousel'>
<ol class='carousel-indicators'>";
$i = 0;
foreach ($images as $image) :
$class = ($i == 0) ? " class='active'" : "";
$carouselMarkup .= "<li data-target='#carousel-$carouselId' data-slide-to='$i'$class ></li>";
$i++;
@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>
<?php
/*
* 401 Response
*
* Sends a 401 Response Unauthorized
*
* @author Camilo Castro
*
* @date 29/07/2014
@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);