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

Recent

Welcome to TinyPortal. Please login or sign up.

March 28, 2024, 08:34:21 AM

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

Print link on articles

Started by jernatety, September 13, 2021, 02:15:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jernatety

Hi, I'm using the latest version TP on 2.17. I noticed in the latest version I had to turn on the edit and print options in the TP settings, which I did. However, when I view articles as a guest the print link doesn't appear. I looked through the SMF guest perms and don't see anything for TP guest options. Is there any way I can have this visible for guests?

Thank you in advance! :)

@rjen

That is correct. The article print link is by default not visible to guests. That's coded in the software and it's been like taht for a long time..

If you want to change it you have to edit 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>';
        }
}

    if($render) {
        echo $data;
    }
    else {
        return $data;
    }
}

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>';
        }
}

    if($render) {
        echo $data;
    }
    else {
        return $data;
    }
}

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

jernatety

Hi rjen, I don't even recall seeing a print option in any other version until the latest so that's something I must've always missed. When I make this change will I have to do the same thing in all future versions as well? As always appreciate the help.

njtweb

Making the change, (did it 4 times to make sure I didn't miss anything. This is the result after saving and then refreshing.

Unable to load the 'tp_above' template.



EDIT
I had no idea I had 2 separate accounts here. I had to login on this laptop because I can't access cpanel on my work laptop.

@rjen

That's what you get giving an answer on the fly..

in my corrected code there was one { missing.
Change to this, that works..


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>';
        }
}

    if($render) {
        echo $data;
    }
    else {
        return $data;
    }
}
Running Latest TP on SMF2.1 at: www.fjr-club.nl

@rjen

Quote from: jernatety on September 13, 2021, 10:27:03 PM
Hi rjen, I don't even recall seeing a print option in any other version until the latest so that's something I must've always missed. When I make this change will I have to do the same thing in all future versions as well? As always appreciate the help.

There is a 'general' option in the "Article settings" in Tinyportal admin to switch the print function on or off in general, but as I stated: it's always deactivated for guests (unless you make the change, and yes, you will have to do that again when you upgrade)

tbh, I personally find this print function is a bit redundant: I for one NEVER used it anywhere. There are plenty ways to copy content from a webpage...
Running Latest TP on SMF2.1 at: www.fjr-club.nl

jernatety

Thank you very much as usual. Here's my case. My oldest went to college this school year and is playing hockey for the university. The local paper rarely writes any stories so I'm taking that on and opening it up for students who might also be interested in writing articles for the team to be posted at my site. Basically they'd submit their article to me and I'd post it in an article page. Then the players can print out the articles for their scrapbooks. I always appreciate your's and the TP team's expert knowledge.

@rjen

I can see the use case but since this is the first request ever I am not sure that this is a reason to change core functionality...
Running Latest TP on SMF2.1 at: www.fjr-club.nl