Skip to content

Instantly share code, notes, and snippets.

@arjenblokzijl
arjenblokzijl / gist:5207400
Last active December 15, 2015 05:09
Example of how to add children to the homepage in ProcessWire. See: http://processwire.com/talk/topic/3065-direct-children-of-default-front-page/.
<?php
// Get the homepage
$homepage = $pages->get("/");
// Get the all the children of home
$children = $homepage->children;
// Get all the homepage children who need to be under home in the menu
$homePageChildren = $homepage->children("homechild=1");
@arjenblokzijl
arjenblokzijl / gist:5622347
Created May 21, 2013 19:05
Fixed an unknown issue on a ProcessWire module. This gist is just temporary.
<?php
/**
*
* Multisite module for Processwire
* (C) 2012 Antti Peisa, Avoine Oy
*
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
@arjenblokzijl
arjenblokzijl / gist:5656671
Last active December 17, 2015 18:58
Test for E-commerce plugin by apeisa
<?php
class ShoppingCheckout extends WireData implements Module, ConfigurableModule
{
public static function getModuleInfo()
{
return array(
'title' => 'Shopping Checkout',
'version' => 001,
'summary' => 'Handles checkout process, order saving etc. Main module for PW Shop',
<?php
// .... module
// create fields and templates using arrays
public function getTemplatesConfig() {
// title | field1 | field2 ...
$templatesArray = array(
'category' => array('title'),
@arjenblokzijl
arjenblokzijl / gist:9272411
Last active April 25, 2018 15:18
Generate ProcessWire pages with random titles, body and image
<?php
for ($i = 1; $i <= 20; $i++)
{
$title = file_get_contents("http://loripsum.net/api/1/plaintext/long/prude/");
$body = file_get_contents("http://loripsum.net/api/3/decorate/link/ul/prude/long/");
$template = "INSERT_TEMPLATE_HERE"; // i.e. 'basic-page'
$parent = "INSERT_PARENT_HERE"; // i.e. /about-us/
$c = new Page();
@arjenblokzijl
arjenblokzijl / pf2pt.php
Created July 8, 2014 18:17
Simple script to convert Page field to Pagetable
<?php
include("index.php");
$pages = wire()->pages;
$stadiums = $pages->find("template=template, field.count>0");
$ptf = "template";
$ptt = "fieldname";
<?php
/**
* ProcessWire example demonstration module
*
* PageListActionHook autoload module once installed will remove "new" action from second level pages
* using the template "basic-page"
*
*/
@arjenblokzijl
arjenblokzijl / Remove system label from template
Last active August 29, 2015 14:08
Remove system label from template
<?php
$template = $templates->get("template_name"); // Insert template name here
$template->flags = Template::flagSystemOverride;
$template->flags = false; // Set flag to false
$template->save();
@arjenblokzijl
arjenblokzijl / wget.sh
Last active August 29, 2015 14:18
Download complete website to local files with wget
# Thanks to: http://snipplr.com/view.php?codeview&id=23838
# --recursive: download the entire Web site.
# --domains website.org: don't follow links outside website.org.
# --no-parent: don't follow links outside the directory tutorials/html/.
# --page-requisites: get all the elements that compose the page (images, CSS and so on).
# --html-extension: save files with the .html extension.
# --convert-links: convert links so that they work locally, off-line.
# --restrict-file-names=windows: modify filenames so that they will work in Windows as well.
# --no-clobber: don't overwrite any existing files (used in case the download is interrupted and resumed).
@arjenblokzijl
arjenblokzijl / processwire-remove-system-flag-from-field.php
Last active April 20, 2017 02:22
ProcessWire remove system flag from field
<?php
$field = $fields->get("field_name_here"); // Insert system field i.e. roles
$field->flags = Field::flagSystemOverride;
$field->flags = 0;
$field->save();