This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ProcessWire example demonstration module | |
* | |
* PageListActionHook autoload module once installed will remove "new" action from second level pages | |
* using the template "basic-page" | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyHelper extends WireData implements Module { | |
/** | |
* getModuleInfo is a method required by all modules to tell ProcessWire about them | |
* @return array | |
*/ | |
public static function getModuleInfo() { | |
return array( | |
'title' => 'My Helper Module', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$children = $pages->get("/shop/")->children(); | |
$list = new PageArray(); | |
function mylist($children, $ind='', $arr){ | |
$ind .= "– "; | |
foreach($children as $cat) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// via field settings | |
$field = $fields->get("title"); | |
echo "width:" . $field->columnWidth; | |
// via template context | |
$tpl = $templates->get("basic-page"); | |
$field = $tpl->fieldgroup->getField("title", true); | |
echo "width:" . $field->columnWidth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// .... module | |
// create fields and templates using arrays | |
public function getTemplatesConfig() { | |
// title | field1 | field2 ... | |
$templatesArray = array( | |
'category' => array('title'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ImageCreateThumbs extends WireData implements Module { | |
public static function getModuleInfo() { | |
return array( | |
'title' => 'ImageCreateThumbs', | |
'version' => 100, | |
'summary' => '', |