1

I have created my business logic in model, but in view part I'm not so expert of how to use JHTML.
Can anyone tell me how can I add a print button in joomla list view?

1
  • What have you tried so far? Have you looked at com_content to see how it's done?
    – Lodder
    Commented Feb 23, 2015 at 9:06

1 Answer 1

2

I don't know if you talk about the frontend or backend... if you are in the Joomla! backend you can create a custom toolbar button in your view.html.php

$bar = & JToolBar::getInstance('toolbar');

$bar->appendButton( 'Print', 'print32', 'Print', 'index.php?option=com_yourcomponent&view=yourviewname&tmpl=component&print=1' );

The second argument is an image if you want a custom image you need to add extra styles in a css file:

.icon-32-print32 {
    background-image: url(../images/print32.png);

}

In your view check for the print variable in the url and put a button if present, for example:

<?php if(JRequest::getVar('print', 0, 'get') == 1) : ?><a href="#" onclick="window.print();" >Click for Printing</a><?php endif; ?>

The toolbar button opens your list without the joomla template but check if your admin template has a component.php file in the template root.

If you are in the frontend check this explanation in the Joomla! Docs https://docs.joomla.org/Adding_print_pop-up_functionality_to_a_component

1
  • yes i'm talking about back-end and yes thanks Commented Feb 25, 2015 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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