TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

October 12, 2024, 10:07:55 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,395
  • Total Topics: 21,244
  • Online today: 215
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 30
  • Total: 30

HTML Article "Printing" format Question

Started by njtweb, October 14, 2022, 07:46:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

njtweb

Hello,

I recently started publishing some articles for the start of the high school hockey season. They look great formatted in all browsers, and on handheld wireless devices when scaled to responsive. These articles will be printed by the kids playing to keep for the scrapbooks. I notice when I hit print the formatting gets all jacked up and the images move all over the place. I've tried adding an excessive amount of line breaks to fix the printing problem but the print view doesn't recognize the breaks.

example, today's article.
youthhockeyinfo.com/index.php?page=368

Any help is greatly appreciated.

tino

I take you mean using the browsers print option.

You would be better of using the following https://ekoopmans.github.io/html2pdf.js as this gives you more control over how it prints.

njtweb

Quote from: tino on October 14, 2022, 08:39:46 PM
I take you mean using the browsers print option.

You would be better of using the following https://ekoopmans.github.io/html2pdf.js as this gives you more control over how it prints.

I click the built in TP print function, and then right click and print.

@rjen

Quote from: njtweb on October 14, 2022, 09:09:50 PM
Quote from: tino on October 14, 2022, 08:39:46 PM
I take you mean using the browsers print option.

You would be better of using the following https://ekoopmans.github.io/html2pdf.js as this gives you more control over how it prints.

I click the built in TP print function, and then right click and print.

I do not see a print link on that page
Running Latest TP on SMF2.1 at: www.fjr-club.nl

jernatety

Quote from: @rjen on October 15, 2022, 07:29:50 AM
Quote from: njtweb on October 14, 2022, 09:09:50 PM
Quote from: tino on October 14, 2022, 08:39:46 PM
I take you mean using the browsers print option.

You would be better of using the following https://ekoopmans.github.io/html2pdf.js as this gives you more control over how it prints.

I click the built in TP print function, and then right click and print.

I do not see a print link on that page

The print link isn't showing for guests, thank you for pointing that out! Is there a TP permission specifically for the print link?

@rjen

It is not a permission, this is one of the functions that is simply not offered to guests...
Running Latest TP on SMF2.1 at: www.fjr-club.nl

njtweb

Quote from: @rjen on October 20, 2022, 07:28:53 AM
It is not a permission, this is one of the functions that is simply not offered to guests...

Is there any way I can make it offered to guests? This is for high school kids to print their articles so they can put them in their scrap books. I'm fine with making a donation. Please let me know, thank you.

@rjen

Running Latest TP on SMF2.1 at: www.fjr-club.nl

njtweb

Quote from: @rjen on October 20, 2022, 01:24:19 PM
Are you willing to hack the code?

If I'm given instruction and its moderate level and doesn't involve modifying several pages I am, but if it's really involved I guess no, unfortunately.

@rjen

#9
In file TPsubs.template.php

find

function article_print($render = true)
{
global $scripturl, $txt, $context;

    $data = '';

if($context['TPortal']['print_articles']==1) {
if(isset($context['TPortal']['article']['boardnews']) && !$context['user']['is_guest']) {
$data .= '
<div class="article_rating"><a href="' . $scripturl . '?action=printpage;topic=' . $context['TPortal']['article']['id'] . '">' . $txt['print_page'] . '</a></div>';
        }
elseif (!$context['user']['is_guest']) {
$data .= '
<div class="article_rating"><a href="' . $scripturl . '?page=' . $context['TPortal']['article']['id'] . ';print">' . $txt['tp-print'] . '</a></div>';
        }
}


and change it to

function article_print($render = true)
{
global $scripturl, $txt, $context;

    $data = '';

if($context['TPortal']['print_articles']==1) {
if(isset($context['TPortal']['article']['boardnews'])) {
$data .= '
<div class="article_rating"><a href="' . $scripturl . '?action=printpage;topic=' . $context['TPortal']['article']['id'] . '">' . $txt['print_page'] . '</a></div>';
        }
else {
$data .= '
<div class="article_rating"><a href="' . $scripturl . '?page=' . $context['TPortal']['article']['id'] . ';print">' . $txt['tp-print'] . '</a></div>';
        }
}
Running Latest TP on SMF2.1 at: www.fjr-club.nl

njtweb

It breaks, and I get this. So I changed back. Attached is the chunk I'm editing.



    Youth Hockey Info

Unable to load the 'tp_above' template.


@rjen

That's what happens trying to give a quick answer: there was one bracket missing...

I updated the code in previous post to the correct new code. Try that
Running Latest TP on SMF2.1 at: www.fjr-club.nl

njtweb

Quote from: @rjen on October 20, 2022, 04:28:53 PM
That's what happens trying to give a quick answer: there was one bracket missing...

I updated the code in previous post to the correct new code. Try that

Perfect! Works like a charm, I greatly appreciate it. Assuming I'll have to make this edit whenever I update the mod, would this be correct?

Thank you very much as always.

@rjen

Yes, with the next version any file edits will be overwritten
Running Latest TP on SMF2.1 at: www.fjr-club.nl

njtweb

Quote from: @rjen on October 20, 2022, 05:25:40 PM
Yes, with the next version any file edits will be overwritten

Okay, thank you very much!