Skip to content

Instantly share code, notes, and snippets.

<?php
// .... module
// create fields and templates using arrays
public function getTemplatesConfig() {
// title | field1 | field2 ...
$templatesArray = array(
'category' => array('title'),
<?php
/* creates a compressed zip file */
function create_zip($files = array(),$destination = '',$overwrite = false) {
if(file_exists($destination) && !$overwrite) { return false; }
if(is_array($files)) {
foreach($files as $name => $file) {
if(!file_exists($file)) unset($files[$name]);
}
}
<?php
// stripped down code
$old_name = 'lizard.jpg';
$new_name = 'wizard';
$p = $pages->find("image.data=$old_name")->first();
$p->of(false); // outputformatting off, single and multiple image fields are from now on wire array's
<?php
// Bootstrap ProcessWire
require 'index.php';
// Make sure that FieldtypeRepeater is installed and ready for use
if (!wire('modules')->isInstalled('FieldtypeRepeater')) {
if (wire('modules')->isInstallable('FieldtypeRepeater')) {
wire('modules')->install('FieldtypeRepeater');
echo "Module FieldtypeRepeater installed\n";
@kongondo
kongondo / pw_configurable_module_example.php
Last active August 29, 2015 13:56
Example Configurable ProcessWire Process Module
<?php
//Example by Ryan Cramer @ProcessWire - http://processwire.com/talk/topic/5480-configurable-process-module-need-walk-through/?p=53729
class YourModule extends WireData implements Module, ConfigurableModule {
public static function getModuleInfo() {
return array('title' => 'Your Module', 'version' => 1);
}
const defaultValue = 'smith';
@kongondo
kongondo / data.php
Created March 12, 2014 00:41 — forked from jjb3rd/data.php
<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2012 - John Becker, Beckersoft, Inc.
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
class TableData {
@kongondo
kongondo / hide-page-tree.php
Last active December 10, 2018 03:17
ProcessWire. Code to hide page tree in the admin
<?php
/*
CODE COPIED FROM https://processwire.com/talk/topic/6142-hide-page-tree-in-the-admin/
One hook returns false for Page::viewable() for the ProcessPageList page.
Another Hook can be used to redirect users to a custom admin page after login.
*/
// This needs to be an autoload module
public function init() {
<?php
/**
* Adding other types of save buttons for page edit form.
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://www.processwire.com
@kongondo
kongondo / member.login.php
Last active August 29, 2015 14:00
ProcessWire: Code example - front-end system to handle logins, password resets and changing passwords
<?php
/*
Code by Ryan Cramer
Integrating a member visitor login form
https://processwire.com/talk/topic/1716-integrating-a-member-visitor-login-form/?p=15919
*/
/*
I recently had to setup front-end system to handle logins, password resets and changing passwords, so here's about how it was done. This should be functional code, but consider it pseudocode as you may need to make minor adjustments here and there. Please let me know if anything that doesn't compile and I'll correct it here.
@kongondo
kongondo / renderPosts
Last active June 21, 2021 02:53
ProcessWire. MarkupBlog's renderPosts() as an independent reusable and editable function outside Blog
function renderPosts($posts, $small = false, Array $options = null) {
$blogConfigs = wire('modules')->getModuleConfigData('ProcessBlog');
//intialise some properties from ProcessBlog config
$commentsUse = $blogConfigs['commentsUse'];
$authorsPage = wire('pages')->get($blogConfigs['blog-authors']);
$settingsPage = wire('pages')->get($blogConfigs['blog-settings']);