Skip to content

Commit

Permalink
[BUGFIX] Remember current template id
Browse files Browse the repository at this point in the history
Ceveat: A template with multiple pages will only use the first page of it

Fixes bithost-gmbh#99
  • Loading branch information
liayn committed Nov 30, 2018
1 parent 3df668a commit 37dd0a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Classes/Model/BasePDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(int $templateId)
{
$this->currentTemplateId = $templateId;
}

/**
* @param bool $importTemplateOnThisPage
*
Expand Down
1 change: 1 addition & 0 deletions Classes/ViewHelpers/PageViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 37dd0a3

Please sign in to comment.