Generate pdf for other component/content-type (not only articles)

Phoca PDF - creating PDF documents in Joomla! CMS
michele.ferretto
Phoca Newbie
Phoca Newbie
Posts: 5
Joined: 13 Aug 2012, 18:22

Generate pdf for other component/content-type (not only articles)

Post by michele.ferretto »

I'm using the excellent Solidres Booking System (www.solidres.com) and investigating the possibility to integrate Phoca PDF in its content-type (in particular Tourist Experiences, which can be booked on the platform).

But you PDF SYSTEM PLUGIN is strictly linked to joomla articles: is there a possibility to create a blank plugin, or override a view which can manage the pdf content, without modify the component core files?

I think a generic system to integrate PDF Component in external components would be very useful

Thanks
mf
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Generate pdf for other component/content-type (not only articles)

Post by Jan »

Hi, the plugin needs to be directly written for each extension. In Phoca PDF there are following plugins:

- content plugin - for articles
- VirtueMart plugin for invoices, delivery note and receipt - not more supported and maintained
- restaurant menu plugin for Phoca Restaurant Menu component
- cart plugin for displaying Invoices, Delivery Notes, Receipts in Phoca Cart

Jan
If you find Phoca extensions useful, please support the project
carcam
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 27 Oct 2011, 11:25

Re: Generate pdf for other component/content-type (not only articles)

Post by carcam »

Hi Jan!!

Thank you very much for PhocaPDF!! It's a really nice framework to allow pdf export in Joomla!!

I'm currently developing a PhocaPDF plugin for JEvents and I have noticed there is something missing in your code which will help with this task.

Right now plugin methods are called from file "administrator/components/com_phocapdf/helpers/phocapdfrender.php". The first event you trigger is onBeforeCreatePDF[COMPONENT] and it's great. But after this, the second trigger: onBeforeDisplayPDF[COMPONENT] is only triggered for your plugins and you do not have a trigger for other third party components.

From my tests I have added this code in the switch:

Code: Select all

default:
			    if (JPluginhelper::isEnabled('phocapdf',strtolower($t))){
			        $results = $dispatcher->trigger('onBeforeDisplayPDF' . $t, array (&$pdf, &$content, &$document, $staticData));
			    }
and it works fine.

Is this something you might consider? I'm aware this is not needed but it will be nice to have it for a better architecture and modularity ;)

Also I will be more than happy to write down all the steps I followed to create this plugin and add it to your PhocaPDF documentation if you just let me know how to send them to you ;)

Thank you very much for the component in any case ;)

Best!!

Carlos
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Generate pdf for other component/content-type (not only articles)

Post by Jan »

Hi, thank you very much for your info, yes, I can implement it in next version and yes, will be great to get more info about the plugin you have created.

Thank you, Jan
If you find Phoca extensions useful, please support the project
carcam
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 27 Oct 2011, 11:25

Re: Generate pdf for other component/content-type (not only articles)

Post by carcam »

Great!!

I have found what I think it is a bug in the current release.

On file /administrator/components/com_phocapdf/views/phocapdfplugin/tmpl/default.php at line 69 you check for the template file to exists:

Code: Select all

if (JFile::exists(JPATH_COMPONENT_ADMINISTRATOR.'/views/phocapdfplugins/tmpl/default_'.$this->item->element.'.php')) {
But you load the template in the phocapdfplugin view ;). So I think it should be:

Code: Select all

if (JFile::exists(JPATH_COMPONENT_ADMINISTRATOR.'/views/phocapdfplugin/tmpl/default_'.$this->item->element.'.php')) {
Best!!
carcam
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 27 Oct 2011, 11:25

Re: Generate pdf for other component/content-type (not only articles)

Post by carcam »

Also I have developed a method to check if image link exists before adding it to the pdf. Would you like to use it in your helpers?
carcam
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 27 Oct 2011, 11:25

Re: Generate pdf for other component/content-type (not only articles)

Post by carcam »

carcam wrote: 18 Apr 2018, 17:37 Hi Jan!!

Thank you very much for PhocaPDF!! It's a really nice framework to allow pdf export in Joomla!!

I'm currently developing a PhocaPDF plugin for JEvents and I have noticed there is something missing in your code which will help with this task.

Right now plugin methods are called from file "administrator/components/com_phocapdf/helpers/phocapdfrender.php". The first event you trigger is onBeforeCreatePDF[COMPONENT] and it's great. But after this, the second trigger: onBeforeDisplayPDF[COMPONENT] is only triggered for your plugins and you do not have a trigger for other third party components.

From my tests I have added this code in the switch:

Code: Select all

default:
			    if (JPluginhelper::isEnabled('phocapdf',strtolower($t))){
			        $results = $dispatcher->trigger('onBeforeDisplayPDF' . $t, array (&$pdf, &$content, &$document, $staticData));
			    }
and it works fine.

Is this something you might consider? I'm aware this is not needed but it will be nice to have it for a better architecture and modularity ;)

Also I will be more than happy to write down all the steps I followed to create this plugin and add it to your PhocaPDF documentation if you just let me know how to send them to you ;)

Thank you very much for the component in any case ;)

Best!!

Carlos
Please forget this request. I just noticed you actually trigger the event on the first switch so my proposal is useless and will make pdf content to be duplicated :(
carcam
Phoca Newbie
Phoca Newbie
Posts: 7
Joined: 27 Oct 2011, 11:25

Re: Generate pdf for other component/content-type (not only articles)

Post by carcam »

Actually, is there a way I can submit a pull request so that you can see my code changes and approve or not them? I think that will be easier for you and I will feel usefull contributing to your extension ;)
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Generate pdf for other component/content-type (not only articles)

Post by Jan »

Hi, which components, plugins are affected by your changes, I will prepare updated code on Github so you can mark the changes there.

Jan
If you find Phoca extensions useful, please support the project
Post Reply