July 11, 2006 - kenshinjeff

Interesting Joomla tips like print and pdf

If you take a look at the default Joomla installation with data, you’ll find that there are links which will allow you to create a “print” page and a “pdf” page easily.

So using that as a reference, I dug somemore, and found that it is freaking easy to create one with your own components.

Say for example the url you want to print looks like this:
http://localhost/index.php?option=com_yourcomponent&task=showdetails&cid=12345

To make Joomla actually show a printable page without the rest of the stuff, your url should look like this:
http://localhost/index2.php?option=com_yourcomponent&task=showdetails&cid=12345

Easy eh? How about pdf you say?
http://localhost/index2.php?option=com_yourcomponent&task=showdetails&cid=12345 &do_pdf=1

Why does this work? A closer look at index2.php shows that it does all the standard stuff, takes in some parameters ( $option, $ItemId, $no_html, $act, $do_pdf ), and loads your template’s index2.php if available.

So technically, you could make Joomla auto print if you wanted to with your own index2.php if you don’t want to bork up Joomla’s code.

Well anyway, I really had to come up with an auto print in a hurry so I had to edit the original index2.php. So there’s a file you have to replace and this is the url you have to call.
http://localhost/index2.php?option=com_yourcomponent&task=showdetails&cid=12345 &auto_print=1

Modified index2.php for auto printing

joomla

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.