Skip to content

Commit

Permalink
BreakRepeaterFields showcase added, README updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromic committed Nov 5, 2017
1 parent 3ab93ce commit 2c76754
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
35 changes: 35 additions & 0 deletions BreakRepeaterFields/BreakRepeaterFields.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace ProcessWire;

class BreakRepeaterFields extends WireData implements Module, ConfigurableModule
{

public static function getModuleInfo()
{
return array('title' => __('BreakRepeaterFields'),
'summary' => __('Showcase of code breaking repeater fields by calling getExportData. You need to create two repeater fields rep1 and rep2 and two text fields text1 and text2. Install this module, then try adding text1 to rep1 and text2 to rep2.'),
'version' => 101,
'singular' => true,
'autoload' => true
);
}

public function init()
{
$this->addHookAfter('ProcessPageView::finished', $this, 'hookProcessPageViewFinished');
}

public function hookProcessPageViewFinished() {
$proc="";
foreach($this->wire('fields') as $field) {

if($field->name=='rep1'||$field->name=='rep2') {
$proc.=$field->name.", ";
$field->getExportData();
}
}
$this->wire('session')->message("processed: ".$proc);

}
}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pw-autoexport-tf - AutoExportTemplatesAndFields module for ProcessWire
## Installation

CAUTION: This module is not compatible with repeater fields or ProFields. See BUGS.

To install this module manually, simply put it into the site/modules directory
of your ProcessWire installation, so that directory should look like this:

Expand Down Expand Up @@ -33,11 +35,12 @@ The import automatically creates a database backup which can be restored using:

### BUGS

* (#1) This module does not seem to work well together with ProFields or when using
repeater fields. See this forum thread:
* (#1) This module is not compatible with repeater fields or ProFields. See this forum thread:

https://processwire.com/talk/topic/13758-autoexporttemplatesandfields-enables-continuous-integration-of-template-and-field-configuration-changes/

The BreakRepeaterFields module is included in the repository as a minimal showcase of what is breaking the repeater fields.

## Contact

I am looking forward to hearing from you: Contact me
Expand Down

0 comments on commit 2c76754

Please sign in to comment.