Mini-How-To: Using a Print Icon in your component

A forum with Tips, tricks and small tutorials.

Moderators: mcsmom, unixboymd

Forum rules
Post Reply
User avatar
mjaz
Joomla! Intern
Joomla! Intern
Posts: 63
Joined: Thu Nov 10, 2005 10:08 am
Contact:

Mini-How-To: Using a Print Icon in your component

Post by mjaz » Sat May 06, 2006 9:24 pm

From a thread in the dev forum (http://forum.joomla.org/index.php/topic,41153)

I don't know if anything was written about this, so I wrote it myself.

Code: Select all

<?php
global $option;

global $hide_js;
// if joomla is called with ?hide_js=1 in the URL, PrintIcon won't work
// if you want to ignore this setting, use the following line instead:
// $hide_js = 1;

$popup = intval( mosGetParam( $_REQUEST, 'popup', 0 ) );

$row = new stdClass; // I don't think $row is used at all.

$params = new mosParameters( '' );

// if set to 0, there won't be a print icon at all
$params->set( 'print', '1' );

// set to 0 to use text instead of icon.
$params->set( 'icons', '1' );

// if set to 1, this will invoke the browser's print function.
$params->set( 'popup', $popup );

// lookup sefRelToAbs in the forum if you don't know what it does.
$link = sefRelToAbs ( 'index2.php?option='.$option.'&popup=1&yourparam=value' );

// if you set status to NULL, or omit it completely,
//these default settings for the print window will be used.
$status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,'
       .'resizable=yes,width=640,height=480,directories=no,location=no';


mosHTML::PrintIcon( $row, $params, $hide_js, $link, $status )

?>
Last edited by mcsmom on Sat Oct 06, 2007 12:22 am, edited 1 time in total.
Joomlatools Team Member - DOCman Lead Developer
http://www.joomlatools.org
Read the blog!
http://blog.joomlatools.org

User avatar
pe7er
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 162
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Mini-How-To: Using a Print Icon in your component

Post by pe7er » Fri Feb 23, 2007 2:30 pm

Thanks for sharing this info!

Do you know by any chance how to create a custom background in the pop-up screen?
(or how to disable template_css so that the background isn't used in the pop-up)?

For people reading your code, sefRelToAbs converts all links in CMTs to SEF links.
Info: http://forum.joomla.org/index.php/topic,1500.0.html
Last edited by pe7er on Fri Feb 23, 2007 2:34 pm, edited 1 time in total.
Kind Regards,
Peter Martin (aka pe7er)
db8.nl - Joomla! implementation, programming, template and component development [Dutch]
>> Questions? Get help more easily with JTS-post Assistant: viewtopic.php?f=428&t=272481

User avatar
mjaz
Joomla! Intern
Joomla! Intern
Posts: 63
Joined: Thu Nov 10, 2005 10:08 am
Contact:

Re: Mini-How-To: Using a Print Icon in your component

Post by mjaz » Fri Feb 23, 2007 4:04 pm

Use [php]$mainframe->addCustomHeadTag()[/php] to add a css file to the popup's html. The css can override anyhting that's in the template's css.
[php]
/**
* Adds a custom html string to the head block
* @param string The html to add to the head
*/
function addCustomHeadTag( $html )[/php]

It should be noted that all of this is for J!1.0.x (or 1.5 with legacy mode)
Joomlatools Team Member - DOCman Lead Developer
http://www.joomlatools.org
Read the blog!
http://blog.joomlatools.org

User avatar
pe7er
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 162
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Mini-How-To: Using a Print Icon in your component

Post by pe7er » Fri Feb 23, 2007 4:57 pm

Thanks!
Kind Regards,
Peter Martin (aka pe7er)
db8.nl - Joomla! implementation, programming, template and component development [Dutch]
>> Questions? Get help more easily with JTS-post Assistant: viewtopic.php?f=428&t=272481

User avatar
mcsmom
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 239
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Mini-How-To: Using a Print Icon in your component

Post by mcsmom » Tue Feb 27, 2007 3:58 pm

Lets say I wanted to add this to a 3rd Party component. Where would I put it?
Read your words before posting and think about how other people will read them. Be polite. Be kind. Be constructive. Say thank you.

User avatar
pe7er
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 162
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

Re: Mini-How-To: Using a Print Icon in your component

Post by pe7er » Tue Feb 27, 2007 4:44 pm

I've put it at the place where I wanted a Print Icon + functionality.
I used the code at three different places, but you might put it in a new function and call that function from the places where you need the Print Icon.
Kind Regards,
Peter Martin (aka pe7er)
db8.nl - Joomla! implementation, programming, template and component development [Dutch]
>> Questions? Get help more easily with JTS-post Assistant: viewtopic.php?f=428&t=272481


Post Reply