• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Variables in PDF template Header and Footer

mediaateam

Administrator
I have a custom PDF template with a header and footer. If I place the divs in the place in the wiki (after: defined('_JEXEC') or die('Restricted access'); and before $form = $this->form;, they work fine, repeating on every page. But, I have a few variables that I would like call into the header, but they aren't assigned until after, so I moved them above the header footer divs, and then I get them in the header on the first page, but the headers and footers do not show up on any other pages.

Here's my code that repeats headers and footers, but doesn't show variable information:

Code:
defined('_JEXEC') or die('Restricted access');
 
 
?>
<div id="footdompdf">
    <span class="footleft">Academy 2015/2016</span>
        <span class="pagenum">Page </span>
</div>
<div id="headerdompdf">
    <span class="headleft">RELEASE PACKET FOR <?php echo $sName; ?> (AppID-<?php echo $sAppID; ?>)</span>
    <span class="pdfdate"><?php echo $rpDate; ?></span>
</div>
<?php
 
$form = $this->form;
$model = $this->getModel();
 
echo $form->intro;
echo '<div class="fabrikForm fabrikDetails" id="' . $form->formid . '">';
echo $this->plugintop;
echo $this->loadTemplate('buttons');
echo $this->loadTemplate('relateddata');
 
$app1Info = $this->groups['Release Packets'];
$app1Keys = $app1Info->elements;
 
$sName = $app1Keys['app_id']->element;
$sAppID = $app1Keys['app_id']->element_raw;
$rpDate = $app1Keys['date_time']->element_raw;

And here's my code that shows the variables, but only has headers and footers on the first page of the pdf:

Code:
defined('_JEXEC') or die('Restricted access');
 
$form = $this->form;
$model = $this->getModel();
 
echo $form->intro;
echo '<div class="fabrikForm fabrikDetails" id="' . $form->formid . '">';
echo $this->plugintop;
echo $this->loadTemplate('buttons');
echo $this->loadTemplate('relateddata');
 
$app1Info = $this->groups['Release Packets'];
$app1Keys = $app1Info->elements;
 
$sName = $app1Keys['app_id']->element;
$sAppID = $app1Keys['app_id']->element_raw;
$rpDate = $app1Keys['date_time']->element_raw;
 
?>
<div id="footdompdf">
    <span class="footleft">Academy 2015/2016</span>
        <span class="pagenum">Page </span>
</div>
<div id="headerdompdf">
    <span class="headleft">RELEASE PACKET FOR <?php echo $sName; ?> (AppID-<?php echo $sAppID; ?>)</span>
    <span class="pdfdate"><?php echo $rpDate; ?></span>
</div>
<?php

Any ideas?
 
You have to set the variables before you use them, in your code example1 you are doing it afterwards (so php will echo empty ones).
 
You have to set the variables before you use them, in your code example1 you are doing it afterwards (so php will echo empty ones).

I tried that in the second code example, but then I only get a header and footer on the first page of the pdf.
 
In your 2nd example you are displaying the dompdfheader/footer divs inside the form's div.
Take you first code but move the variable definitions.
 
AH! I see what you're saying now. Worked like a charm! So the key is that the header/footers need to be OUTSIDE the form's div. For some reason, I was thinking you needed the $form and $model declared before you started assigning any other variables, luckily I was was wrong, lol.
Thanks troester!

Here's my final code in case any one else uses the thread:
Code:
defined('_JEXEC') or die('Restricted access');
 
$app1Info = $this->groups['Release Packets'];
$app1Keys = $app1Info->elements;
 
$sName = $app1Keys['app_id']->element;
$sAppID = $app1Keys['app_id']->element_raw;
$rpDate = $app1Keys['date_time']->element_raw;
 
?>
<div id="footdompdf">
    <span class="footleft">Academy 2015/2016</span>
        <span class="pagenum">Page </span>
</div>
<div id="headerdompdf">
    <span class="headleft">RELEASE PACKET FOR <?php echo $sName; ?> (AppID-<?php echo $sAppID; ?>)</span>
    <span class="pdfdate"><?php echo $rpDate; ?></span>
</div>
<?php
 
$form = $this->form;
$model = $this->getModel();
 
echo $form->intro;
echo '<div class="fabrikForm fabrikDetails" id="' . $form->formid . '">';
echo $this->plugintop;
echo $this->loadTemplate('buttons');
echo $this->loadTemplate('relateddata');
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top