From 6c7552670e6d23a0eaaf22efccbeee9075c9949b Mon Sep 17 00:00:00 2001 From: Jean-Luc Jumpertz Date: Mon, 17 Feb 2014 10:15:21 +0100 Subject: [PATCH] Set $page to the user-visible container page if the hanna code is in a repeater field Also added a $group variable to refer to the repeater page (null if the field is not in a repeater). Note: no change has been done to $this->page to avoid side effects. This means that $page, $hanna->page and wire("page") may have different values. --- TextformatterHannaCode.module | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/TextformatterHannaCode.module b/TextformatterHannaCode.module index 7ba09e7..81bc26e 100644 --- a/TextformatterHannaCode.module +++ b/TextformatterHannaCode.module @@ -389,10 +389,20 @@ class TextformatterHannaCode extends Textformatter implements ConfigurableModule foreach(wire() as $key => $value) { if($key != 'page') $t->set($key, $value); } - + + // set $page to the page containing the field, taking into account the repeater case + if ($this->page instanceof RepeaterPage) { + $repeaterPage = $this->page; + $page = $fieldGroup->getForPage(); + } + else { + $page = $this->page; + } + // populate $page and $hanna variables that are context specific // note $page may be different from wire('page') - $t->set('page', $this->page); + if ($repeaterPage) $t->set('group', $repeaterPage); + $t->set('page', $page); $t->set('hanna', $this); return $t->render();