Page 1 of 1

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

Posted: 09 Apr 2018, 11:13
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

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

Posted: 16 Apr 2018, 11:56
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

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

Posted: 18 Apr 2018, 17:37
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

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

Posted: 19 Apr 2018, 17:00
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

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

Posted: 19 Apr 2018, 18:32
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!!

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

Posted: 19 Apr 2018, 18:48
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?

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

Posted: 19 Apr 2018, 19:23
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 :(

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

Posted: 20 Apr 2018, 09:50
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 ;)

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

Posted: 22 Apr 2018, 14:44
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