[RC] Printer-friendly topic view mod

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

[RC] Printer-friendly topic view mod

Post by Svyatozar »

Welcome!

Download the most recent version of printer-friendly mod, v 1.0.6:
http://wiking.sourceforge.net/phpBB2/pr ... _1.0.6.zip

Printer-friendly topic mod for versions 2.0.4/2.0.6 of phpBB adds a printer button on the topic view page, which leads to a lightweight view of the topic, which is more suitable for printing.

Since Monday, October 3, this is an officially released mode. This thread will probably be locked soon, so here is the new support thread for this mod:
http://www.phpbb.com/phpBB/viewtopic.php?t=141443

October 17, 2003: A new version of this mod is out!
I invite you to preview it on my demo site
(just press on the printer there):
:arrow: http://bbs.inglia.ru/viewtopic.php?t=1
Pagination demo:
:arrow: http://bbs.inglia.ru/viewtopic.php?t=1& ... msgcount=4

Latest released version is 1.0.6

Recently added features in the latest version 1.0.6 include:
- this mod is now 100% easymod-friendly
- reader can now specify starting message number and either last message number or number of messages to print. In the latter case the second number must be negative
- code is reorganized
- bug fixes

Changelog
1.0.1 - 1.0.2:
- an option to view whole topic without pagination. This is made possible by introducing an HTTP_GET_VAR named msgcount, which valure overrides the default board's messages-per-page value, but only in the printer-friendly output mode.
- the printer button is now language-independent
- it is now possible to go from one page to another while staying in printer-friendly mode
- somewhat less ambiguous way of separating messages on the output


1.0.0 - 1.0.1:
- now pages beyond page 1 can be printed as well
- no more signatures in the printer view
- polls results are always printed for all polls


See also: http://phpbbhacks.com/viewhack.php?id=1004 (may be not up-to-date).

For your convenience, here is a link to the section of this topic related to the last updated version of this message:
http://www.phpbb.com/phpBB/viewtopic.ph ... c&start=77
Last edited by Svyatozar on Tue Nov 04, 2003 2:27 am, edited 39 times in total.
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

jlin
Registered User
Posts: 26
Joined: Sat Feb 01, 2003 5:25 pm

Post by jlin »

Hi,

the printer friendly mod doesn't print the 2nd, 3rd, 4th, etc... page
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

Thanks for reporting that bug.
Here's a quick fix:

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
# 

viewtopic.php 

# 
#-----[ FIND ]------------------------------------------ 
# 

$printer_topic_url = append_sid("viewtopic.$phpEx?printertopic=1&" . POST_TOPIC_URL . "=$topic_id"); 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

$printer_topic_url = append_sid("viewtopic.$phpEx?printertopic=1&" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&vote=viewresult"); 

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 
I will make a bugfix release shortly which will include this bug fix as well.
Good luck!
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

Version 1.0.1 released, d/load address is the same. It includes all the bug fixes to all bugs known at this moment. For upgrade information see the bottom of the install.txt file.
Please, report any bugs right away.

Have fun!
leander
Registered User
Posts: 25
Joined: Tue Feb 25, 2003 12:10 pm

Post by leander »

Code: Select all

#-----[ OPEN ]------------------------------------------ 
# 

templates/subSilver/viewtopic_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
#

<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr> 
	<td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&&&<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="middle" width="100%"><span class="nav">&&&<a href="{U_INDEX}" class="nav">{L_INDEX}</a> 
	  -> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
  </tr>
</table>

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr> 
	<td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&&&<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a>&&&<a href="{U_PRINTER_TOPIC}"><img src="{PRINTER_IMG}" border="0" alt="{L_PRINTER_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="middle" width="100%"><span class="nav">&&&<a href="{U_INDEX}" class="nav">{L_INDEX}</a> 
	  -> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
  </tr>
</table>

# 
#-----[ FIND ]------------------------------------------ 
#

<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
  <tr> 
	<td align="left" valign="middle" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&&&<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="middle" width="100%"><span class="nav">&&&<a href="{U_INDEX}" class="nav">{L_INDEX}</a> 
	  -> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
	<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span> 
	  </td>
  </tr>

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 

<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
  <tr> 
	<td align="left" valign="middle" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&&&<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a>&&&<a href="{U_PRINTER_TOPIC}"><img src="{PRINTER_IMG}" border="0" alt="{L_PRINTER_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="middle" width="100%"><span class="nav">&&&<a href="{U_INDEX}" class="nav">{L_INDEX}</a> 
	  -> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
	<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span> 
	  </td>
  </tr>

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
The last thing you're asked to replace does not exist. Not even in a new fresh viewtopic_body.tpl file.

The line:

Code: Select all

<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span> 
only occurs once in the file, and the code around it is:

Code: Select all

<table width="100%" cellspacing="2" cellpadding="2" border="0">
  <tr> 
	<td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&&&<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a>&&&<a href="{U_PRINTER_TOPIC}"><img src="{PRINTER_IMG}" border="0" alt="{L_PRINTER_TOPIC}" align="middle" /></a></span></td>
	<td align="left" valign="middle" width="100%"><span class="nav">&&&<a href="{U_INDEX}" class="nav">{L_INDEX}</a> 
	  -> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
  </tr>
</table>
	<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span></td>
  </tr>
  <tr>
	<td align="left" colspan="3"><span class="nav">{PAGE_NUMBER}</span></td>
  </tr>
</table>
The code at the top here is the area that I've already replaced. So you see that there is nothing left to replace that consist the line:

Code: Select all

<td align="right" valign="top" nowrap="nowrap"><span class="gensmall">{S_TIMEZONE}</span><br /><span class="nav">{PAGINATION}</span>
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

Sorry for such a late response.

First of all, IF you are upgrading from a previous version you only should read the upgrade info in the bottom of that text file.

Anyway, what we are doing in that file viewtopic_body.tpl, is basically adding the Printer buttons to the page. We add one in the top and one in the bottom.

I understand that your version of phpBB might be already modded with another mod, so you should look for similar places. I suggest using WinMerge or a better dif utility to compare files - that may become the only way to mode the highly-modded versions of phpBB. This mod presumes that you apply it to a plain (vanilla) version of phpBB.

Please, tell me if my answer is satisfying. I hope that this info will be helpful.

Svyatozar
tealnet
Registered User
Posts: 13
Joined: Tue Apr 01, 2003 3:38 am
Location: California

Print all pages

Post by tealnet »

Is there a way that it could be instructed to print all pages at once?
User avatar
Remix_88
Registered User
Posts: 46
Joined: Wed Apr 23, 2003 12:52 pm
Location: Hampshire, UK

Printer Friendly Pagination

Post by Remix_88 »

Hi,

Thanks for the Mod, I have integrated it in to my forum. However, I noticed that when viewing the printer friendly pages, the pagination links pointed to the regular 'viewtopic.php' rather than 'viewtopic.php?printertopic=1'.

I reckon that once someone is viewing the printer friendly page they want it to stay that way until they close it? Here are the modifications which will add printer friendly pagination links to this mod.

Code: Select all

#-----[ OPEN ]------------------------------------------ 
# 

/viewtopic.php

#-----[ FIND ]------------------------------------------ 
# 

$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);

#-----[ ADD, AFTER ]------------------------------------------ 
# 

$print_pagination = generate_pagination("viewtopic.$phpEx?printertopic=1&" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult", $total_replies, $board_config['posts_per_page'], $start);

#-----[ FIND ]------------------------------------------ 
# 

'PAGINATION' => $pagination,

#-----[ ADD, AFTER ]------------------------------------------ 
# 

'PRINT_PAGINATION' => $print_pagination,

#-----[ OPEN ]------------------------------------------ 
# 

/templates/subSilver/printertopic_body.tpl

#-----[ FIND ALL]------------------------------------------ 
#

{PAGINATION}

#-----[ REPLACE WITH]------------------------------------------ 
#

{PRINT_PAGINATION}

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
Regards, Remix_88.
captain alban
Registered User
Posts: 49
Joined: Sun Nov 03, 2002 8:48 pm
Location: Paris, France
Contact:

Post by captain alban »

Good idea for a MOD.

I think there is an typo in your install.txt

Code: Select all

##         templates/subSilver/printer_header.tpl
##         templates/subSilver/printer_header.tpl
should be :

Code: Select all

##         templates/subSilver/printer_header.tpl
##         templates/subSilver/printertopic_body.tpl
Then, I think you should have a look at your code regarding the link to the forum homepage that is put at the beginning of the "printed" page. It does not seem to handle forum homepages that are not at the root.
My forum homepage is http://www.captain-alban.net/forums/index.php
but your code points to http://www.captain-alban.net/index.php
(before you ask, yes, my forum is set correctly).

You should put your printer.gif in the images/lang_xxx
with the code :

Code: Select all

$images['printer'] = "$current_template_images/{LANG}/printer.gif";
Then, you can add "local" printer.gif. I found a French one on
http://www.forumimages.com/

I think tealnet's idea of being able to print all the post at once is a good idea. In fact I was expecting the mode to do this, not to keep the pagination.
You should propose this, at least as an option.

Then, I agree also with Remix_88. This is definitely how it should work. I will try his code later.

Hope it helps.
captain alban
Registered User
Posts: 49
Joined: Sun Nov 03, 2002 8:48 pm
Location: Paris, France
Contact:

Post by captain alban »

captain alban wrote: Then, I think you should have a look at your code regarding the link to the forum homepage that is put at the beginning of the "printed" page. It does not seem to handle forum homepages that are not at the root.
My forum homepage is http://www.captain-alban.net/forums/index.php
but your code points to http://www.captain-alban.net/index.php
(before you ask, yes, my forum is set correctly).

It may come from here :

Code: Select all

	'U_INDEX' => append_sid('../index.'.$phpEx),
You'd rather set an absolute URL (using the forum settings) than a relative one.
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

I will update the mod with all the good stuff, I promise.

All the best!

-Svyatozar
Last edited by Svyatozar on Sun Jul 06, 2003 12:03 am, edited 1 time in total.
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

Please, do not mind the button internalization issue. Im going to change the design in the next version of the mod so there will be no text on the buttons that will come with it!

All the best!

Svyatozar
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

Hello!

I invite you to check out the preview of the upcoming version of the mod (version 1.0.2), which is to be released this week if everything goes well.

Here is the demo page:
http://bbs.inglia.ru/viewtopic.php?t=1
Because there is not many pages in that topic you can use this link to test pagination:
http://bbs.inglia.ru/viewtopic.php?t=1& ... msgcount=4

I thank you for all the previous suggestions, which I did implement into upcoming release, as I promised. Please, report any further bugs/suggestions here, in this forum.

Regards,

Svyatozar
Svyatozar
Registered User
Posts: 153
Joined: Fri Apr 12, 2002 5:38 am

Post by Svyatozar »

Hello!

Version 1.0.2 of the mod is out!

You can download it from same old location:
http://wiking.sourceforge.net/phpBB2/pr ... opic_1.zip

Remember to backup all files before modifying them.

Please, report any bugs/suggestions.

Have fun!
Locked

Return to “[2.0.x] MODs in Development”