On Friday, 30 November 2012 09:12:08 UTC+10, Reuben wrote:
My current hair brained scheme is to do the following:--$view = new View();$data = $this->MyModel->getForPrint($id); $view->element('MyModel/print', array('print' => $data, 'fileName' => $fileName)); /* continue processing */Unfortunately, I've still got quite a way to go before I can test that this will work, so if there are any better suggestions, please let me know.One thing to note is that this may not be appropriate for a class element where output is expected to be returned from the $view->element call. However, since the element is calling the FPDF library, and it is taking care of writing the file to disk, it may work in this case.RegardsReuben Helms
On Friday, 30 November 2012 08:40:30 UTC+10, Reuben wrote:I have some functionality that I'm currently migrating from CodeIgniter 1.7.3 to CakePHP 2.2.3, and I'm wondering how best to tackle a particular scenario.The currently functionality that I'm migrating reads data from the database, and will generate a PDF file via FPDF.Currently, I have a controller that will give an option to print to screen, or print to file. In both cases, the controller action will access the model to get the information it needs for printing, and then will call render('print') to generate the PDF. The printToFile action will pass a file name which will indicate to FPDF to output to a file, rather than stream to the browser.The print view calls an element, passing the data and filename, to actually generate the PDF.Now, I have a different controller, that will probably be migrated to a shell or task (since it is run from the command line), that wants to call the print to file functionality, but I'm not sure how to arrange it. I've generally felt that one controller calling the functionality of another controller is bad form, so I'm looking for ideas. One possibility is to call the element functionality directly, from the controller(/shell/task), but that may not be such a good idea, either.In CodeIgniter, I had a library function that I would call from the controller that would use FPDF directly.Can any give me some pointers on calling View functionality repeated from a batch (whether it be from a Controller, as it is at the moment, or a Shell/Task, as it may end up getting migrated to)? Keeping in mind that PDF generation is not the only thing that the batch files does, so control needs to be passed back to the batch file at some point, to keep processing.RegardsReuben Helms
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment