KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Export package - passing parameters #511

Open EGROW SOLUTIONS, LLC opened this topic on on Nov 4, 2018 - 3 comments

EGROW SOLUTIONS, LLC commented on Nov 4, 2018

Hello,

I am exporting a html file like below - this does not work - is there a way to pass parameters?

$template = "myReportTemplate.php?id=25&s=0";
use \koolreport\instant\Exporter;
   Exporter::export($template)
    ->pdf(array(
        "format"=>"Letter",
        "orientation"=>"portrait",
        "margin"=>array(
          "top"=>"0.5in",
          "bottom"=>"0.5in",
          "left"=>"0.5in",
          "right"=>"0.5in"
        )
    ))
    ->toBrowser("exported-report.pdf",true);
KoolReport commented on Nov 5, 2018

Currently you may use the $GLOBALS variables.

$GLOBALS["exporter"] =array(
    "id"=>25,
    "a"=>0,
);

$template = "myReportTemplate.php?id=25&s=0";
use \koolreport\instant\Exporter;
   Exporter::export($template)
    ->pdf(array(
        "format"=>"Letter",
        "orientation"=>"portrait",
        "margin"=>array(
          "top"=>"0.5in",
          "bottom"=>"0.5in",
          "left"=>"0.5in",
          "right"=>"0.5in"
        )
    ))
    ->toBrowser("exported-report.pdf",true);

And then in your myReportTemplate you can access the $GLOBALS["exporter"]

It sounds not yet a nice solution but it works for now. We will find improvement for this.

Peter Harari commented on Nov 18, 2019

Hello,

Did you guys improved this or it still the only solution?

Thank you.

KoolReport commented on Nov 19, 2019

Thanks for asking, yes, we have improved it, now you can do:

Exporter::export("myfile.php",array(
    "param1"=>"value1",
    "param2"=>"value2",
))->pdf(array(
    "format"=>"Letter",
    "orientation"=>"portrait",    
))->toBrowser("myfile.pdf",true);

In the myfile.php, you will receive parameters with $param1, $param2.

Note: This improvement belongs to Instant package

Hope that helps.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

Export