TinyPortal

Development => Support => Topic started by: njtweb on October 14, 2022, 07:46:19 PM

Title: HTML Article "Printing" format Question
Post by: njtweb on October 14, 2022, 07:46:19 PM
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.
Title: Re: HTML Article "Printing" format Question
Post by: 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.
Title: Re: HTML Article "Printing" format Question
Post by: 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.
Title: Re: HTML Article "Printing" format Question
Post by: @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
Title: Re: HTML Article "Printing" format Question
Post by: jernatety on October 19, 2022, 04:16:33 PM
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?
Title: Re: HTML Article "Printing" format Question
Post by: @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...
Title: Re: HTML Article "Printing" format Question
Post by: njtweb on October 20, 2022, 01:19:18 PM
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.
Title: Re: HTML Article "Printing" format Question
Post by: @rjen on October 20, 2022, 01:24:19 PM
Are you willing to hack the code?
Title: Re: HTML Article "Printing" format Question
Post by: njtweb on October 20, 2022, 01:37:07 PM
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.
Title: Re: HTML Article "Printing" format Question
Post by: @rjen on October 20, 2022, 03:14:39 PM
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>';
        }
}
Title: Re: HTML Article "Printing" format Question
Post by: njtweb on October 20, 2022, 03:30:45 PM
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.

Title: Re: HTML Article "Printing" format Question
Post by: @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
Title: Re: HTML Article "Printing" format Question
Post by: njtweb on October 20, 2022, 05:06:11 PM
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.
Title: Re: HTML Article "Printing" format Question
Post by: @rjen on October 20, 2022, 05:25:40 PM
Yes, with the next version any file edits will be overwritten
Title: Re: HTML Article "Printing" format Question
Post by: njtweb on October 20, 2022, 05:27:17 PM
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!