TinyPortal

Development => Support => Topic started by: jernatety on May 17, 2019, 04:53:43 PM

Title: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 17, 2019, 04:53:43 PM
Is there a way to do this for the recent topics block? I just added a whole bunch of new forums and don't want the new topics showing up. Currently every new topic is showing up and in the recent list.

Thank you
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 17, 2019, 05:17:32 PM
Nope, not without coding
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 17, 2019, 05:39:17 PM
Ok, thank you.
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 17, 2019, 06:50:39 PM
Had a quick look at it. If you don't mind getting your hands (a bit) dirty you can adapt the code in TPsubs.template.php.

Easiest way is to just INCLUDE the board that you do want in the recent topics.

Find this code:

// TPortal recent topics block
function TPortal_recentbox()
{
global $scripturl, $context, $settings, $txt, $modSettings, $forum_version;

// is it a number?
if(!is_numeric($context['TPortal']['recentboxnum']))
$context['TPortal']['recentboxnum']='10';

// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb = $modSettings['recycle_board'];
else
$bb = 0;

$include_boards = null;

$what = ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'] , $exclude_boards = array($bb),  $include_boards, $output_method = 'array');


and change the line :
    $include_boards = null;

You can add an array including all the board id's that you want included in the recent topics..

like so:
    $include_boards = array(1,2,3,24,26);

The numbers are the board id's to be included
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: lurkalot on May 17, 2019, 07:18:39 PM
There's also this php block snippet which does seem to work in SMF2. just tried it.

It has many options which you might find useful for your needs, and I'm sure with a bit of tweaking you could get it looking the way you want too.

Just follow the instructions, Multi-Functional posts and topics snippet (https://www.tinyportal.net/index.php?topic=33026.0)
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 17, 2019, 07:57:44 PM
Ok, here is how to exclude. You will have to put the board id's in an array twice.

Find:

// TPortal recent topics block
function TPortal_recentbox()
{
global $scripturl, $context, $settings, $txt, $modSettings, $forum_version;

// is it a number?
if(!is_numeric($context['TPortal']['recentboxnum']))
$context['TPortal']['recentboxnum']='10';

// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb = $modSettings['recycle_board'];
else
$bb = 0;

$include_boards = null;

$what = ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'] , $exclude_boards = array($bb),  $include_boards, $output_method = 'array');


and replace with


// TPortal recent topics block
function TPortal_recentbox()
{
global $scripturl, $context, $settings, $txt, $modSettings, $forum_version;

// is it a number?
if(!is_numeric($context['TPortal']['recentboxnum']))
$context['TPortal']['recentboxnum']='10';

// leave out the recycle board, if any, to exclude certain boards put board id's in $bb array below
if(isset($modSettings['recycle_board']))
$bb = array($modSettings['recycle_board'],26,70,19);
else
$bb = array(26,70,19);

// to include only certain boards put board id's in array below
$include_boards = array();

$what = ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'] , $exclude_boards = $bb,  $include_boards, $output_method = 'array');


You need to replace the string 26,70,19 in the code with the list of board ID's you wish to exclude. You need to do that in TWO places...
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 18, 2019, 03:02:19 PM
Thank you @Mick, I think I'm going to go with @rjen's 2nd suggestion.

@rjen, does the second suggestion also get reconfigured in "TPsubs.template.php"

And @rjen, you didn't have to do that, I can assure you though I greatly appreciate it.

Thanks, Ross
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 18, 2019, 03:08:14 PM
Yep, same file
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: lurkalot on May 18, 2019, 03:15:56 PM
Quote from: jernatety on May 18, 2019, 03:02:19 PM

Thank you @Mick, I think I'm going to go with @rjen's 2nd suggestion.


No worries, was just throwing it into the mix.  ;)
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 18, 2019, 03:19:17 PM
Quote from: @rjen on May 18, 2019, 03:08:14 PM
Yep, same file

I don't see this file in the current theme ACP. In the sources directory I do see a TPsubs.php file but not .template.pnp file.

Am I looking in the correct place?
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 18, 2019, 03:26:27 PM
It's a template not a source. Look in themes/default
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 18, 2019, 03:43:18 PM
Quote from: @rjen on May 18, 2019, 03:26:27 PM
It's a template not a source. Look in themes/default

Got it. TY
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 18, 2019, 03:54:56 PM
I made that change and added the following ID's. I still see Labeda Pharaoh's, id 1164 on the front page recent topics block.

// TPortal recent topics block
function TPortal_recentbox()
{
global $scripturl, $context, $settings, $txt, $modSettings, $forum_version;

// is it a number?
if(!is_numeric($context['TPortal']['recentboxnum']))
$context['TPortal']['recentboxnum']='10';

// leave out the recycle board, if any, to exclude certain boards put board id's in $bb array below
if(isset($modSettings['recycle_board']))
$bb = array($modSettings['recycle_board'],384,385,386,1164);
else
$bb = array(384,385,386,1164);

// to include only certain boards put board id's in array below
$include_boards = array();
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 18, 2019, 04:01:43 PM
Are you sure that is the correct board is? Seems VERY high
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 18, 2019, 04:12:02 PM
Quote from: @rjen on May 18, 2019, 04:01:43 PM
Are you sure that is the correct board is? Seems VERY high

Sorry, you're right. That is a topic#. The board id is 383. I added that, saved, reloaded and did Shift F5 on the page and still see the topics from that forum ID in recent.

// TPortal recent topics block
function TPortal_recentbox()
{
global $scripturl, $context, $settings, $txt, $modSettings, $forum_version;

// is it a number?
if(!is_numeric($context['TPortal']['recentboxnum']))
$context['TPortal']['recentboxnum']='10';

// leave out the recycle board, if any, to exclude certain boards put board id's in $bb array below
if(isset($modSettings['recycle_board']))
$bb = array($modSettings['recycle_board'],383,384,385,386);
else
$bb = array(383,384,385,386);

// to include only certain boards put board id's in array below
$include_boards = array();
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 18, 2019, 04:14:06 PM
Strange, it should work. Other boards are excluded successfully?
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: @rjen on May 18, 2019, 06:50:51 PM
Topic showing 'Labeda Pharaohs' is not posted in board 383! It is posted in board 397, which is a child board of 383.

When excluding board you will need to exclude board number 397. The exclusion of a parent board will NOT automatically exclude all its child boards...
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 18, 2019, 08:41:35 PM
Hi, sorry, I went on a bike ride with my wife and kids. You are 100% correct. Works perfectly. I was assuming the child forums were picked up under the parents. I put them all in and the code did exactly what you said it would do.

Perfect! Thank you!
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: lurkalot on May 19, 2019, 10:49:14 AM
Glad @rjen got you sorted on this one.  O0

If I'm honest, it would be nice if these were block options for the recent block, it's been Number 1 on my ideas for TP list since at least 2017.  Whether it will ever make it to core, I'm not sure, but it's been requested a few times over the years.

Maybe drop a request in the "TinyPortal Feature Requests board". https://www.tinyportal.net/index.php?board=246.0
Title: Re: A way to block ID's for specific forums from showing up in Recent Topics?
Post by: jernatety on May 19, 2019, 01:08:41 PM
Quote from: lurkalot on May 19, 2019, 10:49:14 AM
Glad @rjen got you sorted on this one.  O0

If I'm honest, it would be nice if these were block options for the recent block, it's been Number 1 on my ideas for TP list since at least 2017.  Whether it will ever make it to core, I'm not sure, but it's been requested a few times over the years.

Maybe drop a request in the "TinyPortal Feature Requests board". https://www.tinyportal.net/index.php?board=246.0

Done! Thanks Mick, you guys are the best.