Recent Topics

1 Feb 13, 2007 22:32    

I got really sick of playing with print.css files for hours and having one browser or another (yeah, I'm looking at you, IE and Opera) not display like all the rest. So I started using a link to the basic skin as my pretty printing page. Here's how it goes down.

Note: I'm using Francois' skin named custom and the skin named basic for this example. Each comes with b2evolution by default. This is designed for b2evolution v1.9.2.

1. If you don't allow skin switching on all your blogs then please skip to step #2.

1.a. Open the _main.php file of all skins. Find the section that lists the time of the post, the post author, the post word count, and what not. That section is sometimes named: bSmallHead.

1.b. Insert the following code, leaving off the php tags if you put this code in a section previously marked by php tags:


<?php
  echo '&nbsp; <a href="';
  $Item->permanent_url();
  echo '3&skin=basic" title="Print: ';
  $Item->title();			
  echo '"><img src="img/print.gif" border="0" /></a>';
?>

1.c. Save the _main.php files and upload them to your server (if needed). Then skip to step # 6.

2. Assuming you haven't altered it, make a copy of your a_stub.php file. Name the new copy: print.php

3.a. Open print.php and uncomment a line. Essentially, replace:

# You could *force* a specific skin here with this setting: (otherwise, default will be used)
# $skin = 'basic';

with:

# You could *force* a specific skin here with this setting: (otherwise, default will be used)
$skin = 'basic';

3.b. Change the blog represented by the print.php stub file so that the same print.php file may be used for every blog. Change:



$blog = 2;   	// 2 is for "demo blog A" or your upgraded blog (depends on your install)

to:



$blog = 1;   	// 2 is for "demo blog A" or your upgraded blog (depends on your install)

4. Save the print.php file, upload it to the same directory as your index.php file, and then be sure it has read and execute permissions.

5. Open the _main.php files of all skins you use except the one named basic. Find the section that lists the time of the post, the post author, the post word count, and what not. That section is sometimes named: bSmallHead.

5.a. Insert the following code, leaving off the php tags if you put this code in a section previously marked by php tags:


<?php
  echo ' &nbsp;<a href="';
  $baseurl;
  echo '/print.php?p=';
  $Item->ID();
  echo '" title="Print: ';
  $Item->title();
  echo '"><img src="img/print.gif" border="0" /></a>';
?>

5.b. Save the _main.php files and upload them to your server (if needed).

6. Save the print.gif icon attached to this forum post. Upload it to a all skin folders , except basic. Be sure the print.gif icon is in a subfolder named img. As an example, using Francois' custom skin, upload the print.gif icon to /skins/custom/img and then be sure it has read and execute permissions.

7. (Optional) Clean up the _main.php file of the basic skin. Find and delete the following:


<?php

	/**

	 * --------------------------- BLOG LIST INCLUDED HERE -----------------------------

	 */

	require( dirname(__FILE__).'/_bloglist.php' );

	// ---------------------------------- END OF BLOG LIST ---------------------------------

	?>



	<?php

	// ------------------------------- START OF SKIN LIST -------------------------------

	if( ! $Blog->get('force_skin') )

	{	// Skin switching is allowed for this blog:

		echo T_( 'Select skin:' ), ' ';

		for( skin_list_start(); skin_list_next(); )

		{ ?>

		[<a href="<?php skin_change_url() ?>"><?php skin_list_iteminfo( 'name', 'htmlbody' ) ?></a>]

		<?php

		}

	}

	// ------------------------------ END OF SKIN LIST ------------------------------

	?>



	<hr>


	<hr>

	<small><?php $Blog->disp( 'longdesc', 'htmlbody' ); ?></small>



	<hr>



	<?php

	// ------------------------- MESSAGES GENERATED FROM ACTIONS -------------------------

	if( empty( $preview ) ) $Messages->disp( );

	// --------------------------------- END OF MESSAGES ---------------------------------

	?>



	<?php request_title( '<h2>', '</h2>' ) ?>


	<hr>



	<div align="center">

		<strong>

		<?php posts_nav_link(); ?>

		::

		<a href="<?php $Blog->disp( 'arcdirurl', 'raw' ) ?>"><?php echo T_('Archives') ?></a>

		</strong>



		<p><?php

			user_login_link( ' [', '] ' );

			user_register_link( ' [', '] ' );

			user_admin_link( ' [', '] ' );

			user_logout_link( ' [', '] ' );

		?></p>

	</div>

That's it. You should be able to click a little print icon in the byline of your posts and see the text in the basic skin if everything worked.

2 Feb 14, 2007 01:08

Great.... works a treat.

3 Mar 07, 2007 02:46

Thank you so much for this walk through... I cannot thank you enough as this was a piece of the puzzle that I really wanted to figure out...

Thank you

D

4 Mar 19, 2007 16:12

Great Work! But when i use the "more" tag in my posts it will only print the teaser. I think it's because of the $Item->ID(); in


  echo ' &nbsp;<a href="';
  $baseurl;
  echo '/print.php?p=';
  $Item->ID();
  echo '" title="Print: ';
  $Item->title();
  echo '"><img src="img/print.gif" border="0" /></a>'; 

Is there another $Item i can use that catchs the right URL with the "more" tag? E.g. everything after the /blog=2? in /blog=2?p=24&more=1&c=1&tb=1&pb=1#more24

Thanks nureac


Form is loading...