Skip to content

Instantly share code, notes, and snippets.

View Da-Fecto's full-sized avatar

Martijn Geerts Da-Fecto

View GitHub Profile
<?php
function getPartial($path_to_file) {
ob_start();
include($path_to_file);
return ob_get_clean();
}
$partial = getPartial($config->urls->templates . 'partials/myfile.php');
@Da-Fecto
Da-Fecto / DescriptionNoteVariables.php
Created October 19, 2015 05:33
Replace PW page variable in field descriptions and notes, eg: [Click Here]({page.parent.url}) for creating a link to the parent page.
<?php
/**
* Replace PW page variable in field descriptions and notes, eg: [Click Here]({page.parent.url})
* for creating a link to the parent page.
*
* @author adrianbj (https://gist.github.com/adrianbj/5dc1c00f1617b2639319)
*/
class DescriptionNoteVariables extends WireData implements Module {
@Da-Fecto
Da-Fecto / conditional-sql.php
Created November 19, 2015 09:16
Conditional SQL on config
/**
* Installer: HTTP Hosts Whitelist
*
*/
$config->httpHosts = array('domain-01.dev', 'domain-02.dev', 'domain-03.dev', 'domain-04.ext');
/**
* Development settings (Switch settings based on domainname.)
*
@Da-Fecto
Da-Fecto / live-page-name.js
Created January 17, 2016 18:06
Live typed pagename.
/**
* Mapping 01
*
* Text manipulator for the set name. The set name must be compatible with Page name.
*
*/
$(function () {
/**
* Build valid/restricted filenames
<?php namespace ProcessWire;
require($config->paths->templates . 'Spout/Autoloader/autoload.php');
use Box\Spout\Writer\WriterFactory;
use Box\Spout\Common\Type;
// $pfields = $page->templates->fields;
$fg = $fieldgroups->get('item');
$allFields = $fg->fields->getAll();
$item = $pages->get('template=item');
$allFields = $item->template->fields;
$lorem_long = array(
/**
* OpenSSL encrypt/decrypt for ProcessWire
*
* $encryptDecrypt = new \ProcessWire\OpenSSLencryptDecrypt();
* $encrypted = $encryptDecrypt->encrypt('My Text');
* $decrypted = $encryptDecrypt->decrypt($encrypted);
*/
class OpenSSLencryptDecrypt extends Wire {
/**