Recent Topics

1 Jul 03, 2006 13:56    

Hi there,

I am trying to add a printer-friendly button. I searched the forum and came up with Yabba solution I am trying to implement: http://forums.b2evolution.net/viewtopic.php?t=6195&highlight=printer+friendly

1/ create a "print" skin

I created a new skin called 'print' so now you have skins > print with only one file left: _main.php. Is it a 'normal' _main.php or do you have to delete or add a new piece of code?

add a "printer friendly" link to your normal skin :-
<a href="<?php echo regenerate_url( 'tempskin', 'tempskin=print'); ?>">printer friendly</a>

I added the printer friendly link

then add this to the top of skins/<normal skin>/_main.php
PHP:
<?php
param( 'tempskin', 'string' );
if( $tempskin == 'print' ){
require_once dirname(__FILE__).'/../<print skin>/_main.php';
exit;
}
?>

I added this code to the top of skins/custom/_main.php

<?php
param( 'tempskin', 'string' );
if( $tempskin == 'print' ){
require_once dirname(__FILE__).'/../print/_main.php';
exit;
}
?> 

This is a copy of the link I get from printer friendly:

http://www.fireworkszone.com/news/index.php?blog=3&page=1&disp=posts&tempskin=print

After, I get a Warning message coming from _bloglist.php:

Unable to access /var/www/42/f/i/r/fireworkszone.com/www/news/skins/print/_bloglist.php in _main.php on line 40

Please could you tell me what am I doing wrong
:oops:

Thanks in advance

2 Jul 03, 2006 16:34

Another approach :
using a print.css

Put this in your _main.php file :

<link rel="stylesheet" href="rsc/print.css" type="text/css" media="print"/>

and something like this in your print.css file

BODY {
   color: black; 
   background: white;
   }
div#wrapper /* Main white content zone */{
   width: 100%;
   }
.bPosts {
   width: 90%;
   font-size : 1.2em;
   margin-top: 0px;
   padding-top: 0px;
   }
.bText img {
   background-color:#cccccc; 
   border:1px solid #000000; 
   padding: 4px;
   margin-left: 2px;
   }
a:link, a:visited {
   background: white; color: black; text-decoration: underline;
   font-weight: bold;
   }
.bComment {
   display: none;
   }
h4 {
   display: none;
   }
div#pageFooter {
   display: none;
   } 
#bloglist {
   display: none;
   } 
.bSmallFoot {
   display: none;
   } 
.bPostTitlepublished, .bPostTitleprotected, .bPostTitleprivate, bPostTitlepublished a {
   margin: 0;
   padding:0px;
   font-weight:600;
   font-size: 150%;
   text-decoration: none;
   }
.bSideItem {
   display: none;
   } 
input.SearchField {
   display: none;
   } 

Every div that is not needed for the article, you put on display:none;

3 Jul 03, 2006 16:57

Sorry, but I would like to stick to this approach B)

4 Jul 04, 2006 07:38

I would like to stick to Yabba's approach and not to the CSS approach. Can anybody tell me what I am doing wrong.

:-/

5 Jul 06, 2006 11:08

In your print skin you have an include for the bloglist, if you delete that line it'll get rid of your error (or copy the file to your print skin directory if you wan't the bloglist on your print skin).

¥

6 Jul 06, 2006 12:58

The 'Printer friendly' button is now working (not quite perfectly):

I created a new skin named print containing 3 files :

. _main.php,
. bloglist.php
. feedback.php
. print.css

Note: the _main.php is coming from the basic skin. I added the print.css to the file

<link rel="stylesheet" href="print.css" type="text/css" media="print"/>

I inserted the code and the link inside my _main.php file

Now, when I click the printer friendly link, I've got this:

http://www.fireworkszone.com/news/index.php?blog=3&paged=1&page=1&disp=posts&tempskin=print

As you can see in the new page I've got 5 posts with a style which is not coming from print.css.

From the page source I can see that _main.php (from basic) is included inside the _main.php from custom skin. There is something wrong about this.

What I would like is 'printer friendly' per post ID. You get only one post as in the Permanent link and you apply the print.css. How can I do that ?

Thanks

7 Jul 08, 2006 09:46

There shouldn't be any of the custom.php in the print skin (the "exit;" stops it from being processed any further)

Remove this line from your print skin :-

<link rel="stylesheet" href="custom.css" type="text/css" />


and change the next line so it looks like this :-

<link rel="stylesheet" href="rsc/print.css" type="text/css" />

In your post loop, add the following code to generate a printer friendly link per post :-

echo '<a href="'.$Item->gen_permalink( 'pid', '', true ).'" title="printer friendly version">Printer friendly version</a>';

¥

8 Jul 11, 2006 09:21

Finally, I came up with this code for a printer friendly button that works. Add this code at the top of your _main.php skin

<?php
param( 'tempskin', 'string' );
if( $tempskin == 'print' ){
require_once dirname(__FILE__).'/print/_main.php';
exit;
}
?>

And the printer friendly link:

<a href="<?php
  echo url_add_param( $Item->gen_permalink(), 'printme=1&amp;skin=print', '1'); ?>" title="Printer friendly |<?php $Item->title(); ?>">Print</a>

The last printer friendly link you gave was not working:

echo '<a href="'.$Item->gen_permalink( 'pid', '', true ).'" title="printer friendly version">Printer friendly version</a>';

Thanks anyway for your help

B)

9 Jul 11, 2006 10:30

Glad you got it working ;)

¥


Form is loading...