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

Forum rules
Please submit all new Tips and Tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
User avatar
mjaz
Joomla! Guru
Joomla! Guru
Posts: 821
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.
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22257
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, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

User avatar
mjaz
Joomla! Guru
Joomla! Guru
Posts: 821
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)
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22257
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, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
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?
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22257
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, Global Moderator
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content


Locked

Return to “Tips & Tricks - Moving”