Recent Topics

1 Jan 20, 2005 03:09    

This is probably not the best or easiest way to do this -- however it does work, you can see it at a simple blog set up just for this at this screenshot:
http://www.village-idiot.org/images/print-ss.png

first you need a print.php in your root b2evolution directory. Like so:


<?php
require_once dirname(__FILE__).'/middle.php';
?>

Now you need middle.php in that same directory. middle.php is a mirror of the root folder's _main.php (if i reme correctly) Like so:


<?php
/**
 * This is the main public interface file!
 *
 * This file is NOT mandatory. You can delete it if you want.
 * You can also replace the contents of this file with contents similar to the contents
 * of a_stub.php, a_noskin.php, multiblogs.php, etc.
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package main
 * Note: we need at least one file in the main package	
 */
require_once dirname(__FILE__).'/b2evocore/_main1.php';


/**
 * First thing: Do the minimal initializations required for b2evo:
 */
// Check if a specific blog has been requested in the URL:
param( 'blog', 'integer', '', true );

if( empty($blog) )
{	// No blog requested, by URL param, let's check extrapath
  # echo 'Checking extra path...<br />';
	// Check and Remove current page url:
	$index_url = substr( $baseurl, strlen( $baseurlroot ) ) . '/middle.php';
  # echo 'Seeking ['.$index_url.'] in ['.$ReqPath.']...<br />';
	if( ($pos = strpos( $ReqPath, $index_url )) !== false )
	{ // note: $pos will typically be 0
    # echo 'Matched index.php path...<br />';
		$path_string = substr( $ReqPath, $pos+strlen( $index_url ) );
		// echo "path=$path_string <br>";
		$path_elements = explode( '/', $path_string, 20 );						// slice it
		if( isset($path_elements[1]) && (($Blog = $BlogCache->get_by_stub( $path_elements[1], false )) !== false) )
		{	// We found a matching blog:
			$blog = $Blog->ID;
		}
	}
}

if( empty($blog) )
{	// Still no blog requested,
	$blog = $Settings->get('default_blog_ID');
}

if( empty($blog) )
{	// No specific blog to be displayed:
	// we are going to display the default page:
	require dirname(__FILE__).'/default.php';
	exit();
}

// A blog has been requested... Let's set a few default params:

# You could *force* a specific skin here with this setting:
# $skin = 'basic';

# This setting retricts posts to those published, thus hiding drafts.
# You should not have to change this.
$show_statuses = array();

# You could *force* a specific link blog here with this setting: (otherwise, default will be used)
# $linkblog = 4;

# This is the list of categories to restrict the linkblog to (cats will be displayed recursively)
# Example: $linkblog_cat = '4,6,7';
$linkblog_cat = '';

# This is the array if categories to restrict the linkblog to (non recursive)
# Example: $linkblog_catsel = array( 4, 6, 7 );
$linkblog_catsel = array( );

# Here you can set a limit before which posts will be ignored
# You can use a unix timestamp value or 'now' which will hide all posts in the past
$timestamp_min = '';

# Here you can set a limit after which posts will be ignored
# You can use a unix timestamp value or 'now' which will hide all posts in the future
$timestamp_max = 'now';

# Additionnaly, you can set other values (see URL params in the manual)...
# $order = 'ASC'; // This for example would display the blog in chronological order...
// That's it, now let b2evolution do the rest! :)
require dirname(__FILE__)."/$core_subdir/_blog_main1.php";

?>

You might notice that I havent edited any of the settings that were left over from the original file. You prolly could delete them, or not. Its up to you.

Now you need a _blog_main1.php inside your b2evocore directory. This is nearly a mirror of _blog_main.php


<?php
/**
 * This file loads the blog!
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evocore
 */

/**
 * Initialize everything:
 */

// Getting GET or POST parameters:
param( 'blog', 'integer', 0, true );  // Can't use $default_to_blog because the param must always be included in regenerate_url() when present
param( 'p', 'integer', '', true );              // Specific post number to display
param( 'm', 'integer', '', true );              // YearMonth(Day) to display
param( 'w', 'integer', -1, true );              // Week number
param( 'cat', 'string', '', true );             // List of cats to restrict to
param( 'catsel', 'array', array(), true );      // Array of cats to restrict to
param( 'author', 'integer', '', true );         // List of authors to restrict to
param( 'order', 'string', 'DESC', true );       // ASC or DESC
param( 'orderby', 'string', '', true );         // list of fields to order by
param( 'posts', 'integer', '', true );          // # of posts to display on the page
param( 'paged', 'integer', '', true );          // List page number in paged display
param( 'poststart', 'integer', '', true );      // Start results at this position
param( 'postend', 'integer', '', true );        // End results at this position
// param( 'search', 'string' );                 // obsolete (dangerous!)
param( 's', 'string', '', true );               // Search string
param( 'sentence', 'string', 'AND', true );     // Search for sentence or for words
param( 'exact', 'integer', '', true );          // Require exact match of title or contents
param( 'preview', 'integer', 0, true );         // Is this preview ?
param( 'calendar', 'string', '', true );        // Display a specific month in the calendar
param( 'c', 'string', '', true );								
param( 'page', 'integer', '', true );
param( 'more', 'integer', 0, true );
param( 'title', 'string', '', true );						// urtitle of post to display
param( 'tb', 'integer', 0, true );
param( 'pb', 'integer', 0, true );
param( 'disp', 'string', '', true );
param( 'stats', 'integer', 0 );                 // deprecated
if( !isset($timestamp_min) ) $timestamp_min = '';
if( !isset($timestamp_max) ) $timestamp_max = '';

if( empty($disp) )
{	// Conversion support for old params:
	if( $c == 'last') 
	{	// Translate old last comments caller
		$disp = 'comments';
	}
	elseif( $stats )
	{	// Translate old stats caller
		$disp = 'stats';
	}
}

// Getting current blog info:
$Blog = Blog_get_by_ID( $blog ); /* TMP: */ $blogparams = get_blogparams_by_ID( $blog );

// Activate matching locale:
debug_log('Activating blog locale: '.$Blog->get('locale'));
locale_activate( $Blog->get('locale') );

// -------------------------
// Extra path info decoding:
// -------------------------
// Check and Remove blog baseurl from ReqPath:
$blog_baseurl = substr( $Blog->get( 'baseurl' ), strlen( $baseurlroot ) );
if( ($pos = strpos( $ReqPath, $blog_baseurl )) !== false )
{ // note: $pos will typically be 0
	$path_string = substr( $ReqPath, $pos+strlen( $blog_baseurl ) );
	// echo "path=$path_string <br>";
	$path_elements = explode( '/', $path_string, 20 );						// slice it
	$i=0;
	// echo $path_elements[$i];
	if( isset( $path_elements[$i] ) && $path_elements[$i] == 'index.php' )
	{ // Ignore index.html
		$i++;
	}
	
	if( isset( $path_elements[$i] ) && preg_match( '#^'.$Blog->get( 'stub' ).'(\.php)?$#', $path_elements[$i] )  )
	{ // Ignore stub file
		$i++;
	}

	// echo $path_elements[$i];
	if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
	{	// We'll consider this to be the year
		$m = $path_elements[$i++];
		
		if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
		{	// We'll consider this to be the month
			$m .= $path_elements[$i++];
	
			if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) )
			{	// We'll consider this to be the day
				$m .= $path_elements[$i++];
	
				if( isset( $path_elements[$i] ) && (!empty( $path_elements[$i] )) )
				{ // We'll consider this to be a ref to a post
					// We are accessing a post by permalink
					// Set a lot of defaults as if we had received a complex URL:
					$m = '';
					$more = 1; // Display the extended entries' text
					$c = 1;    // Display comments
					$tb = 1;   // Display trackbacks
					$pb = 1;   // Display pingbacks

					if( preg_match( "#^p([0-9]+)$#", $path_elements[$i], $req_post ) )
					{	// The last param is of the form p000
						// echo 'post number';
						$p = $req_post[1];		// Post to display
					}
					else
					{ // Last param is a string, we'll consider this to be a post urltitle
						$title = $path_elements[$i];
						// echo 'post title : ', $title;
					}
				}
			}
		}
		elseif( isset( $path_elements[$i] ) && substr( $path_elements[$i], 0, 1 ) == 'w' )
		{	// We consider this a week number
			$w = substr( $path_elements[$i], 1, 2 );
		}
	}
}

if( (!empty($p)) || (!empty($title)) || (!empty($preview)) )
{	// We are going to display a single post
	$disp = 'single';
}

if( empty( $disp ) )
{ // default display:
	$disp = 'posts';
}

if( ($disp == 'posts') || ($disp == 'single') )
{ // If we are going to display posts and not something special...

	// On single post requests, check if we're on the right blog!
	if( $redirect_to_postblog && ( $disp == 'single' ) )
	{	// Yes we need to check.
		if( !empty($p) )
			$Item = Item_get_by_ID( $p );	// TODO: use cache
		else
			$Item = Item_get_by_title( $title );	// TODO: use cache
			
		if( ($Item !== false) && ($Item->blog_ID != $blog) )
		{	// We're on the wrong blog (probably an old permalink) let's redirect
			$new_permalink = $Item->gen_permalink( '', '', false, '&' );
      # echo $new_permalink;
			header ("Location: $new_permalink");
			exit();
		}
	}

	// Note: even if we request the same post, the following will do more restrictions (dates, etc.)
	$MainList = & new ItemList( $blog, $show_statuses, $p, $m, $w, $cat, $catsel, $author, $order, 
															$orderby, $posts, $paged, $poststart, $postend, $s, $sentence, $exact,
															$preview, '', '', $timestamp_min, $timestamp_max, $title );
	
	$posts_per_page = $MainList->posts_per_page;
	$what_to_show = $MainList->what_to_show;
	$request = & $MainList->request;
	// $result = & $MainList->result;
	$result_num_rows = $MainList->get_num_rows();
	$postIDlist = & $MainList->postIDlist;
	$postIDarray = & $MainList->postIDarray;
}
else
{	// we are not trying to display posts:
	$result_num_rows = 0;
}

// Default display params:

// Displaying of vlog list on templates?
if( !isset($display_blog_list) )
{	// If not already set in stub:
	$display_blog_list = get_bloginfo('disp_bloglist');
}

/*
 * Now, we'll jump to displaying!
 */
if( !isset( $skin ) ) 
{ // No skin forced in stub (not even '' for no-skin)...

	// We're going to need a default skin:
	if(  ( !isset( $default_skin ) ) 					// No default skin forced in stub
		|| ( !skin_exists( $default_skin ) ) )	// Or the forced default does not exist
	{	// Use default from the datatabse
		$default_skin = $Blog->get('default_skin');
	}
	
	if( !skin_exists( $default_skin )	|| empty( $default_skin ) )
	{ // blog's default skin does not exist
		// Because a lot of bloggers will set themseleves a cookie and delete the default skin,
		// we have to make this fool proof extra checking!
		printf( T_('The default skin [%s] set for blog [%s] does not exist. It must be properly set in the <a %s>blog properties</a> or properly overriden in a stub file. Contact the <a %s>webmaster</a>...'), $default_skin , $Blog->dget('shortname'), 'href="'.$admin_url.'/b2blogs.php?action=edit&amp;blog='.$Blog->ID.'"', 'href="mailto:'.$admin_email.'"');
		die();
	}

	if( $Blog->get('force_skin') )
	{	// Blog params tell us to force the use of default skin
		$skin = $default_skin;
	}
	else
	{	// Get the saved skin in cookie or default:
		param( $cookie_state, 'string', $default_skin );
		// Get skin by params or default to cookie 
		// (if cookie was not set, the $$cookie_state contains default skin!)
		param( 'skin', 'string', $$cookie_state );
	}
}

// At this point $skin holds the name of the skin we want to use, or '' for no skin!

// check to see if we want to display the popup or the main template
param( 'template', 'string', 'main', true );

if( !empty( $skin ) )
{	// We want to display now:
	
	if( (!empty($_GET['skin'])) || (!empty($_POST['skin'])) )
	{	// We have just asked for the skin explicitely
		// Set a cookie to remember it:
		// Including config and functions files
		if( ! setcookie( $cookie_state, $skin, $cookie_expires, $cookie_path, $cookie_domain) )
		{	// This damn failed !
			echo "<p>setcookie failed!</p>";
		}
		// Erase OLD versions cookies:
		if( ! setcookie( 'b2evostate', '', $cookie_expired, $cookie_path, $cookie_domain) )
		{	// This damn failed !
			echo "<p>setcookie failed!</p>";
		}
		if( ! setcookie( 'b2evostate', '', $cookie_expired, '/') )
		{	// This damn failed !
			echo "<p>setcookie failed!</p>";
		}
	}

	if( ereg( '([^-A-Za-z0-9._]|\.\.)', $skin ) )
	{
		// echo ("<p>Invalid skin name!</p>");
		$skin = $default_skin;
	}
	elseif( !skin_exists($skin) )
	{
		// echo "<p>Oops, no such skin!</p>";
		$skin = $default_skin;
	}

	if( $template == 'popup' )
	{	// Do the popup display
		require get_path( 'skins' )."/$skin/_popup.php";
	}
	else
	{	// Do the main display
		require get_path( 'skins' )."/$skin/_main1.php";
	}
}
else
{	// we don't want to use a skin
	if( $template == 'popup' )
	{	// Do the popup display
		require get_path( 'skins' ).'/_popup.php';
		exit();
	}
	// If we end up here the blog file should be a full template, not just a stub...
}
?>


and a _main1.php inside your b2evocore directory..


<?php
/**
 * This file initializes everything BUT the blog!
 *
 * It is useful when you want to do very customized templates!
 * It is also called by more complete initializers.
 * 
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2004 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evocore
 */
if( isset( $main_init ) )
{	// Prevent double loading since require_once won't work in all situations
	// on windows when some subfolders have caps :(
	// (Check it out on static page generation)
	return;
}
$main_init = true;

/**
 * Includes:
 */
require_once( dirname(__FILE__).'/../conf/_config.php' );
require_once( dirname(__FILE__).'/_functions.php' );

timer_start();

require_once( dirname(__FILE__).'/_vars.php' );	// sets various arrays and vars for use in b2
require_once( dirname(__FILE__).'/_class_settings.php' );
require_once( dirname(__FILE__).'/_class_db.php' );
require_once( dirname(__FILE__).'/_functions_template.php' );	// function to be called from templates
require_once( dirname(__FILE__).'/_functions_xmlrpc.php' );	
require_once( dirname(__FILE__).'/_functions_xmlrpcs.php' );
require_once( dirname(__FILE__).'/_class_blog.php' );
require_once( dirname(__FILE__).'/_class_itemlist.php' );
require_once( dirname(__FILE__).'/_class_itemcache.php' );
require_once( dirname(__FILE__).'/_class_commentlist.php' );
require_once( dirname(__FILE__).'/_class_archivelist.php' );
require_once( dirname(__FILE__).'/_class_dataobjectcache.php' );
require_once( dirname(__FILE__).'/_class_calendar.php' );
require_once( dirname(__FILE__).'/_functions_hitlogs.php' ); // referer logging
require_once( dirname(__FILE__).'/_functions_forms.php' );
require_once( dirname(__FILE__).'/_class_renderer.php' );
require_once( dirname(__FILE__).'/_class_toolbars.php' );


if( !$config_is_done )
{	// base config is not done.
	$error_message = 'Base configuration is not done.';
	require dirname(__FILE__).'/_conf_error.page.php';	// error & exit
}


if( !function_exists( 'gzencode' ) )
{ // when there is no function to gzip, we won't do it
	$use_gzipcompression = false;
}

if( $use_obhandler )
{ // register output buffer handler
	ob_start( 'obhandler' );
}


// Connecting to the db:
$DB = new DB( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST, $db_aliases );

$Settings = & new Settings();

$servertimenow = time();
$localtimenow = $servertimenow + ($Settings->get('time_difference') * 3600);


debug_log('default_locale from conf: '.$default_locale);

locale_overwritefromDB();
debug_log('default_locale from DB: '.$default_locale);

$default_locale = locale_from_httpaccept(); // set default locale by autodetect
debug_log('default_locale from HTTP_ACCEPT: '.$default_locale);

// Activate default locale:
locale_activate( $default_locale );


// Object caches init:
$GroupCache = & new DataObjectCache( 'Group', true, $tablegroups, 'grp_', 'grp_ID' );
$BlogCache = & new BlogCache();
$ItemCache = & new ItemCache();


// Plug-ins init:
$Renderer = & new Renderer();
$Toolbars = & new Toolbars();


// Login procedure:
if( !isset($login_required) ) $login_required = false;
if( $error = veriflog( $login_required ) )
{	// Login failed:
	require(dirname(__FILE__) . "/$core_dirout/$htsrv_subdir/login.php");
}

if( is_logged_in() && $current_User->get('locale') != $default_locale )
{ // change locale to users preference
	$default_locale = $current_User->get('locale');
	locale_activate( $default_locale );
	debug_log('default_locale from user profile: '.$default_locale);
}


// Load hacks file if it exists
//@include_once( dirname(__FILE__) . '/../conf/hacks.php' );
?>

Now you need a _main1.php inside your skins directory and any skins you use (subdirectories). Its the file thats actually called when youre looking at the page to be printed.


<?php
/*
 * This is the main template. It displays the blog.
 *
 * However this file is not meant to be called directly.
 * It is meant to be called automagically by b2evolution.
 * To display a blog, you should call a stub file instead, for example:
 * /blogs/index.php or /blogs/blog_b.php
 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php locale_charset() ?>" />
<title><?php
	$Blog->disp('name', 'htmlhead');
	single_cat_title( ' - ', 'htmlhead' );
	single_month_title( ' - ', 'htmlhead' );
	single_post_title( ' - ', 'htmlhead' );
	arcdir_title( ' - ', 'htmlhead' );
	profile_title( ' - ', 'htmlhead' );
	last_comments_title( ' - ', 'htmlhead' );
	stats_title( ' - ', 'htmlhead' );
?>
</title>
<base href="<?php skinbase(); // Base URL for this skin. You need this to fix relative links! ?>" />
<style type="text/css" media="screen">
Body {
	font-family: Arial, Verdana Tahoma;
	color: #000000;
}
#Outline {
	text-align: left;
	width: 90%;
	margin-left: auto; 
	margin-right: auto;
	padding: 10px;
	border: 1px solid #000000;
}
#BlogTitle {
	font-weight: bold;
	font-size: 16px;
	margin-bottom: 5px;
}
#BlogDate {
	margin-top: 5px;
	margin-bottom: 10px;	
}
#BlogContent {
	margin-top: 10px;
}
HR#Divider {
	width: 80%; 
	height: 1px; 
	color: #000000;
}

#menu {
	display: none;
}
.header {
	display: none;
}

</style>
<script language="JavaScript" src="easydynfont.js"></script>
<link rel="stylesheet" type="text/css" media="print" href="http://www.yourdomain.com/print.css" />
</head> 
<body onload="init()">

<table class="noprint" align="center" style="border: 1px solid #000000; background: #CCCCCC; width: 90%;">
<tr><td align="center"><script language="JavaScript">drawform();</script></td></tr>
</table>
</span>
<p align="center"><b>- http://www.yourdomain.com -</b></p>
<div id="Outline">
<?php // ------------------------------------ START OF POSTS --------------------------------------
	if( isset($MainList) ) $MainList->display_if_empty();	// Display message if no post

	if( isset($MainList) ) while( $Item = $MainList->get_item() )
{
?>
<!-- =================================== START OF MAIN AREA =================================== -->
<p id="BlogTitle"><b><?php $Item->title(); ?></b></p>
<p id="BlogDate"><?php echo T_('Filed under:'); ?> <?php $Item->categories(); ?> ? <?php $Item->Author->prefered_name() ?> @ <?php $Item->issue_time() ?> on <?php $Item->issue_date() ?>
	
	<div id="BlogContent"><?php $Item->content(); ?></div>
<p><hr id="Divider" align="center"></p>
		<p align="left">Article printed from <b>put your domain name here</b></p>

		<p align="left">URL to article: <b><?php $Item->permalink() ?></b></p>
		<p align="right" class="noprint">Click <a href="javascript:window.print();">here</a> to print.</p>
</div>
<?php }  // ---------------------------------- END OF POSTS ------------------------------------ ?>

</body></html>

easydynfont.js which is called in the above file looks like this:


/*
	Easydynfont 
	Version 1.0
	written by Chris Heilmann
	please refer to the homepage at http://www.onlinetools.org/tools/easydynfont.php 
*/

// Standard setting, separate fonts with "," and make sure to set standardfont
// and size to avoid errors
var fonts="Arial,Times New Roman,Verdana,Courier".split(",");
var standardfont="Arial"
var standardsize="90%"
var nosave=false; 

/* 
	function drawform()
	adds the standard form to the document.
*/
function drawform(){
    if (!document.layers){
	document.write("<form action=\"/\" name=\"dynform\" class=\"dynform\">");
	document.write("<select class=\"dynselect\" name=\"typeface\" onchange=\"setFont(this.options[this.selectedIndex].value)\">");
	for (i=0;i<fonts.length;i++){
		document.write("	<option value=\""+fonts[i]+"\">"+fonts[i]+"</option>");
	}
	document.write("</select>");
	document.write("<input type=\"button\" class=\"dynbutton\" onclick=\"addSize(-10)\" value=\"smaller\" />");
	document.write("<input type=\"button\" class=\"dynbutton\" onclick=\"addSize(10)\" value=\"larger\" />");
	document.write("<input type=\"checkbox\" name=\"nosave\" /><span>Don't store as default.</span>");
	document.write("</form>");
	}
}

/* 
	function init()
	loads the cookiedata and changes the document accordingly, if there is no 
	cookie, sets the standard settings and stores it 
*/
function init(){
    if (!document.layers){
	size=getCookie("dynfontsize");
	if (size!=null){
		c=size.split(":");
		document.getElementsByTagName("body").item(0).style.fontSize=c[0];
		document.getElementsByTagName("body").item(0).style.fontFamily=c[1];
	}
	if (size==null || c[0]=="" || c[1]==""){
		document.getElementsByTagName("body").item(0).style.fontSize=standardsize;
		document.getElementsByTagName("body").item(0).style.fontFamily=standardfont;
		storeSize()
		}
	}
	// Special setting, if you want to use the "don't save" chekbox
	nosave=document.dynform.nosave.checked
}		
/* 
	function addSize(add)
	increases the size of the document font by "add", negative values make the 
	font smaller.
*/
function addSize(add){
    if (!document.layers){
	doc = document.getElementsByTagName("body").item(0)
	size=parseInt(doc.style.fontSize)+add;
	doc.style.fontSize=size+"%";
	if (nosave==false) storeSize()
	}
}
/* 
	function SetSize(add)
	sets the font size of the document.
*/
function setSize(add){
    if (!document.layers){
	document.getElementsByTagName("body").item(0).style.fontSize=add+"%";
	if (nosave==false) storeSize() 
	}
}

/* 
	function SetFont(add)
	sets the font face of the document.
*/
function setFont(add){
    if (!document.layers){
	doc = document.getElementsByTagName("body").item(0)
	doc.style.fontFamily=add;
	if (nosave==false) storeSize()
	}
}

/* 
	function storeSize()
	saves the current settings of the document in a cookie
*/
function storeSize(){
	var exp = new Date();
	exp.setTime(exp.getTime() + 24*60*60*90*1000);
	size=document.getElementsByTagName("body").item(0).style.fontSize;
	font=document.getElementsByTagName("body").item(0).style.fontFamily;
	setCookie("dynfontsize",size+":"+font,exp);
}
/* 
	function setCookie()
	sets the cookie
*/
function setCookie(name, value, expires, path, domain, secure) { 
	var curCookie = name + "=" + escape(value) + 
	((expires) ? "; expires=" + expires.toGMTString() : "") + 
	((path) ? "; path=" + path : "") + 
	((domain) ? "; domain=" + domain : "") + 
	((secure) ? "; secure" : "") 
	document.cookie = curCookie 
} 
/* 
	function getCookie()
	reads the cookie
*/
function getCookie(name) { 
	var prefix = name + "=" 
	var cookieStartIndex = document.cookie.indexOf(prefix) 
	if (cookieStartIndex == -1) 
	return null 
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + 
	prefix.length) 
	if (cookieEndIndex == -1) 
	cookieEndIndex = document.cookie.length 
	return unescape(document.cookie.substring(cookieStartIndex + 
	prefix.length, 
	cookieEndIndex)) 
} 


and print.css looks like this:


/* This is the stylesheet modern browser will use to print your pages. */

a {
	color: #000;
}

body {
	font-family: serif;
	font-size: 12pt;
}

#content {
	margin: 0px;
	padding: 0px;
	width: auto;
}

#header, h3, h4, .storytitle {
	border: none;
	font-weight: bold;
	margin: 0px;
	padding: 0px;
	width: auto;
}

#main {
	float: none;
	margin: 0px 10%;
	padding: 0px;
	width: auto;
}

#menu {
	display: none;
}
.header {
	display: none;
}
.noprint {
	display: none;
}
#script {
	display: none;
}

Like I said, its sloppy, but it works. The duplication of the files came from needing to edit out certain portions of _main.php that you obviously wouldnt want displayed on a printed page.

I can zip up all of the files inside of the necessary dirs also if anyone would find that easier to follow.

Im betting someone else can do this much easier, but if youre willing to go through the steps, well there you have it.

2 Jan 20, 2005 03:14

PS: the links on that blog (http://www.village-idiot.org/b2evo-archived/) are not set up correctly and there is only one post. If you change skins using the skin changer you will be redirected to another blog install completely. Dont let that get you confused.

Rather than leave the blog up unattended, I took a screenshot of what the resulting page looks like -- its up at http://www.village-idiot.org/images/print-ss.png

also, I forgot to mention how to link to the actual print page:

<a href="http://www.yourdomain.com/print.php?p=<?=the_ID()?>" title="Print <?php $Item->title(); ?>">Print this Item</a>

3 Apr 02, 2005 18:47

I can zip up all of the files inside of the necessary dirs also if anyone would find that easier to follow.

If you would I would appreciate it....

Thanks,

W. Hill

4 Apr 02, 2005 20:47

I will try it morrow....

bye till then

mikel

5 Apr 02, 2005 20:57

re4med,

it actually would be easier for me to sort of walk you through it, since i dont know what skin youre using -- if you have aol's aim or yahoo messenger, or even ICQ, or you spend aytime on irc let me know in a pm, and we "get together" online in a way thats more realtime. I can use just about any chat program except msn messenger, its broke, and ive never bothered to fix it.

6 Apr 03, 2005 02:17

whoo wrote:

re4med,

it actually would be easier for me to sort of walk you through it, since i dont know what skin youre using -- if you have aol's aim or yahoo messenger, or even ICQ, or you spend aytime on irc let me know in a pm, and we "get together" online in a way thats more realtime. I can use just about any chat program except msn messenger, its broke, and ive never bothered to fix it.

Okay..I sent you a PM. Thanks!

W. Hill

7 Apr 03, 2005 11:56

a _main1.php inside your b2evocore directory..

must be _main1.php and than

and then I get

Fatal error: Call to a member function on a non-object in \b2evocore\_main1.php on line 16

maybe the wrong directory?

sorry, it doesn't work

mikel

8 Apr 03, 2005 20:07

re4med,

i got your pm..

and mikel,

ill zip up the files and pm both of you where you can download them,, so you can look at my own edits

also, re4med, ill add you to my aim, so you can reach me this afternoon or evening

ill zip them up as soon as i get a cup of coffee in me :)

9 Jul 21, 2005 22:10

hey whoo, can I get some help for mine? I'm having trouble understanding how my regular skin links to the printer version.

10 Jul 21, 2005 22:51

Maybe I'm missing something, but it seems like it would be simpler just to create a print-friendly skin, and create a link that specifies that skin in the URL for your print-friendly version. That's a lot less hacking and extra files.

The CSS spec allows you to create different style sheets for different mediums, allowing you to simply specify one style sheet for on-screen display and a different one for print (in which you would probably just disable the display of the sidebar and other unecessary stuff). I have no idea of that is actually supported by any of the browsers, though.

11 Jul 22, 2005 16:44

Kweb,

I use CSS a LOT in my day job, and I can tell you that print CSS is not (yet) all it's cracked up to be. It's very tricky, and almost every print-thing is handled differently by different browsers, much worse than screen media. IE completely ignores every page-break directive except page-break-after:always, it doesn't re-print the thead and tfoot elements when a table spans multiple pages, images get screwey (or are replaced by their ALT attrib, or omitted completely), you can't reliably specify the layout (portrait vs landscape) cross-browser in any way that I've seen, the list goes on.

However, there IS a MUCH easier way to do this than re-creating _main.php and _blog_main.php - that's about as hacky as hacks get.

Create a new skin called "print". In skins/print/_main.php, set it up just like any other skin (you could even copy one of the existing skin folders, and just name it "print" to start with.)

Once that's done, strip out everything that you won't want to print (linkblog, calendar, search, etc.) out of that print skin.

Put your print.js in the skins/print folder. You could even get fancy and add something like this to your skins/print/_main.php:


<?php
if( $_GET['printme'] ) {
  ?>
  <script type="text/javascript"><!--
    window.onload = function() {
      window.focus();
      window.print();
      if( confirm('Go back to regular view?') )
        window.location.replace('<?php
          echo add_url_param($Item->gen_permalink, 'skin=' . $Blog->get('default_skin'));
        ?>');
    }
  </script>
  <?php
}
?>

Then, in all your OTHER skins (possibly only in the single view), inside the blog loop where you do the categories, feedback link, etc., add a link like this:

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

Just a few thoughts.

12 Jul 22, 2005 17:14

That's what I figured, isaac. CSS has a lot of features that I'd love to use, if only the browsers would implement them correctly.

The print-friendly skin seems like the way to go.

13 Sep 11, 2005 18:30

all the other links will be look like printable mode... (sorry for my bad english, I'm from Argentina)

which is the code to modify the skin cookie whithout need the link to go back?

thanks

14 Nov 04, 2006 22:50

So I figured I would revive this thread since I tried to apply this to my site and am having problems.

I used Isaac's method, but when i go to put the link at the bottom of the page I receive the following error:

Fatal error: Call to undefined function: gen_permalink()

This occurs on the line I added (obviously) and I am wondering if it is because gen_permalink is the incorrect function for these newer versions of b2evo or something.

Also, along the same lines, how would I get this to put a link to print on only the single post view instead of at the bottom of every post, even if its not the whole post (because I only put teasers on the main page)

Thanks,
Marcus

15 Feb 28, 2007 23:17

any chance that someone could enlighten us on how to get this going? would really appreciate it as it is a clean solution...

D

16 Mar 03, 2007 21:31

Is there a way to prevent the "Comments" Form from printing? I would want the comments to print but not the actual form. I was thinking of enclosing the form within a DIV and then doing the print.css trick in which you do

#Section {display: none;}

If you agree, what are the lines of code that load the comments form?

I see:
$disp_comment_form = 1; &
"include for _lastcomments.php"

But they don't look right... thoughts?


Form is loading...