Skip to content

Instantly share code, notes, and snippets.

View jacmaes's full-sized avatar

Jacques Maes jacmaes

View GitHub Profile
@SkyLundy
SkyLundy / hook_use_separate_address_field_for_fieldtype_map_marker.php
Created November 6, 2024 20:32
Use a separate field to control the address for a FieldtypeMapMaker field
<?php
declare(strict_types=1);
namespace ProcessWire;
/**
* Sets the map address from the address subfields
*
* This uses a ProFields Custom Field called address with subfields to store the address
@SkyLundy
SkyLundy / hook_show_message_while_editing_a_page.php
Created November 6, 2024 19:16
Show the user a message when editing a page if conditions are met
<?php
declare(strict_types=1);
namespace ProcessWire;
/**
* Conditionally display a message while editing a page
*/
wire()->addHookAfter('ProcessPageEdit::buildForm', function(HookEvent $e) {
@SkyLundy
SkyLundy / object-hook-methods-RepeaterMatrixPage_get_matrix_children.php
Created November 6, 2024 15:28
Add a 'getMatrixChildren()' method to RepeaterMatrixPage objects
<?php
declare(strict_types=1);
namespace ProcessWire;
/**
* Custom method that gets nested child RepeaterMatrixPage objects as a PageArray for the
* RepeaterMatrixPage executed upon. This simulates accessing RepeaterMatrix items as pages
*
@millipedia
millipedia / calculate_reading_time.php
Last active December 20, 2021 12:23
Processwire hook to calculate article reading time
<?php
/**
*
* Calculate reading time on page save.
* Add this to your ready.php file.
* Uses a field called 'article_read_time' to store the value
* and the field 'page_content' as the readable content.
* You'll need to update those field names if yours are different.
*
@hdragomir
hdragomir / sm-annotated.html
Last active February 2, 2025 02:22
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@grandmanitou
grandmanitou / gist:8863248
Created February 7, 2014 14:10
Place multiple markers with infowindow on Google Maps API v3, use external links to trigger click and center map on desired location.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?language=fra&amp;sensor=false"></script>
<script type="text/javascript">
var map;
var Markers = {};
var infowindow;
var locations = [
[
'Samsung Store Madeleine',
'<strong>Samsung Store Madeleine</strong><p>5 Boulevard Malesherbes, 75008 Paris<br>10h – 20h</p>',
48.8701925,
@davatron5000
davatron5000 / Sublime Text Setup.md
Last active April 15, 2023 15:39
A new user's guide to SublimeText 2. Estimated reading time: 2 mins. Estimated workthrough time: 12 minutes.

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@Da-Fecto
Da-Fecto / RepeaterTable.module
Last active December 22, 2015 15:38
create table from repeater
<?php
class RepeaterTable extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'RepeaterTable',
'version' => 100,
'summary' => 'RepeaterTable',
'singular' => false,
@toddmotto
toddmotto / gist:5477991
Created April 28, 2013 18:56
Center Google Maps Marker positioning on window.resize
google.maps.event.addDomListener(window, 'resize', function() {
var center = map.getCenter()
google.maps.event.trigger(map, "resize")
map.setCenter(center)
})
@somatonic
somatonic / upload_images_to_page_form.php
Created November 26, 2012 22:08
Upload Images to new created Page Form Example
<?php
// front-end form example with multiple images upload
// add new page created on the fly and adding images
$message = '';
if($input->post->submit){
// tmp upload folder for additional security