2

Is it possible to add output formats to a component? For example, if I wanted to have a pdf output from com_content article, how would this be done?

The article view only has a single format listed (in /components/com_content/views/article/) view.html.php, and I have not found a standard way of adding output formats. I know I can probably make a separate tmpl file in my template, and add the necessary headers and code there, but that does not really look like the "correct" way to do it.

Also, if there is a good way to override view.html.php, I'd be happy to know how.

3

To do it the "correct" way, you would have to create a /components/com_content/views/article/view.pdf.php file and generate the PDF there (using a layout is optional). This file will be loaded using the URL parameter &format=pdf.

  • Is it fair to add that this file would be fairly resistant to core updates, unless the core added a view.pdf.php file? – David Fritsch Sep 1 '14 at 20:25
  • OK, thanks Bakual, you seem to be everywhere these days. Is there no way to do this from the template, or from a plugin? Your suggestion would possibly be overwritten by changes to the joomla core. – jonasfh Sep 1 '14 at 20:30
  • I believe as David has indicated that it would only be overwritten if Joomla added a 'view.pdf.php' to the core. – Craig Sep 1 '14 at 21:22
  • Imho it should be safe as stated. Doing it on template level is hard because Joomla will already output HTML headers. – Bakual Sep 2 '14 at 6:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.