From d959c91f85b7dba8b3ff8c8c588575ef08faffed Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Fri, 30 Nov 2018 14:43:17 +0100 Subject: [PATCH] [BUGFIX] Remember current template id Ceveat: A template with multiple pages will only use the first page of it Fixes #99 --- Classes/Model/BasePDF.php | 14 ++++++++++++-- Classes/ViewHelpers/PageViewHelper.php | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Classes/Model/BasePDF.php b/Classes/Model/BasePDF.php index 80a2400..95c076c 100755 --- a/Classes/Model/BasePDF.php +++ b/Classes/Model/BasePDF.php @@ -96,6 +96,11 @@ class BasePDF extends Fpdi */ protected $currentPageFormat = ''; + /** + * @var int + */ + protected $currentTemplateId = 0; + const SCOPE_THIS_PAGE = 'thisPage'; const SCOPE_THIS_PAGE_INCLUDING_PAGE_BREAKS = 'thisPageIncludingPageBreaks'; const SCOPE_DOCUMENT = 'document'; @@ -196,11 +201,16 @@ public function AddPage($orientation = '', $format = '', $rotationOrKeepmargins $this->renderHeader(); } - if ($this->importTemplateOnThisPage && $this->tpl !== 0) { - $this->useTemplate($this->tpl); + if ($this->importTemplateOnThisPage && $this->currentTemplateId) { + $this->useTemplate($this->currentTemplateId); } } + public function setCurrentTemplateId($templateId) + { + $this->currentTemplateId = $templateId; + } + /** * @param bool $importTemplateOnThisPage * diff --git a/Classes/ViewHelpers/PageViewHelper.php b/Classes/ViewHelpers/PageViewHelper.php index ecb2714..725e1c1 100755 --- a/Classes/ViewHelpers/PageViewHelper.php +++ b/Classes/ViewHelpers/PageViewHelper.php @@ -94,6 +94,7 @@ public function render() $this->getPDF()->AddPage($this->arguments['orientation'], $this->arguments['format']); if ($hasImportedPage) { + $this->getPDF()->setCurrentTemplateId($templateId); $this->getPDF()->useTemplate($templateId); }