1

I'm new to Joomla and I'm confused, so I need your advice on this. I have to create a plugin which connects to an API and shows base64 PDF on a page. So, I created my PDF viewer, but I don't know how to pack it up in Joomla. It's not just "custom HTML", it has to be a separate package so it can be installed on other Joomla sites. I guess it also has to have a database to store some settings (e.g. API URL). I want users who install this extension to be able to go to Modules > New Module > PDF Viewer, and from there they can set up API URL for that module. Users will be able to create modules of this type on multiple pages and to be able to set different API URL for every page. So, what do I need? An extension, component, module...? I searched for tutorials and read Joomla docs but I'm still confused. Please help me, what to do, some guide, where to put files, where to upload them etc. Thanks

demian
  • 93
  • 1
  • 2
  • 6

1 Answers1

0

You could actually go about this with a component, plugin or module:

I think a component would be the most complex in this situation. As you are probably already aware, a component is like an application which renders itself in the main click of the website.


If you were to create a plugin, you could generate a short code snippet based on the name of the plugin which could then be added to an article, which would then display the PDF within the article. For example:

{PDFgen=NAME_OF_PDF}

or

{PDF}name_of_file.pdf{/PDF}

Creating a module in my opinion would be the easiest. As once you've added the functionality to render the PDF, the user can either display it as a module (like a sidebar widget), or they can also import it in their article using a built in Joomla feature. Assign a custom position to the module, then add the following anywhere within an article: {loadposition XXX}, where XXX is the name of the custom position you assigned to the module.


Out of all honest, you should develop it in a way you feel most comfortable with. Just make sure when you do it, that you stick to Joomla coding standards.

Hope this helps

Lodder
  • 19,758
  • 10
  • 59
  • 100
  • thanks, but I need to use PDFJS library, so I have some javascript, html and css files, and also have to have configuration for API URL on each instance of that module. how to pack it all up and set it up? any guide? – demian Oct 09 '14 at 14:24
  • Well that all depends on which extension type you go with. One chosen, have a look at the Joomla documentation for importing JS and CSS file – Lodder Oct 09 '14 at 14:27
  • I want to create a module, pack it as ZIP and be able to import it on multiple sites, and then add it on multiple pages from Modules > New > PDF Viewer, and I also want to be able to set some configuration for each instance. I found nothing about it in Joomla docs, I really don't know how it's done, please tell me where can I read about it – demian Oct 09 '14 at 14:44
  • Please have a look at the [Module Development](http://docs.joomla.org/Portal:Module_Development) docs. To get you started, you may also find my [Module Generator](http://joomjunk.co.uk/extras-page/module-generator.html) useful – Lodder Oct 09 '14 at 14:46
  • ok I generated module with generator and it created tags in module.xml. That's just what I need, but just how to access those parameters from module.php? I really, really can't find anything on google or Joomla docs – demian Oct 09 '14 at 15:31
  • @demian - to get a value from a parameter, simply use `$value = $params->get('param_name');`. You of course need to change `param_name` to the name of the field in your XML – Lodder Oct 09 '14 at 15:35