TinyPortal

Development => Block Codes => Topic started by: Thurnok on January 27, 2007, 12:36:26 AM

Title: [Block] Only display "stuff" on certain boards
Post by: Thurnok on January 27, 2007, 12:36:26 AM
Ok... this question has been asked a couple times, so I figured I would give you at least some sort of solution.  If you want to display a block (for example a center block) only on certain boards / subboards, here's a solution for you.

First, whether you have center blocks hidden from forum or not (via TinyPortal Settings page) this will work.  You should not display a title or frame for your block, otherwise, an empty block will show up on boards other than those you designate.

Here's the block code "template" to use:

global $context;
// what board numbers to display on?
// example: array(3,7,9);
$disp_on_boards = array();

if (in_array($context['current_board'], $disp_on_boards)){
// your content here!
echo "This is only displayed on certain boards!<br />";
echo "Since you see this, you are obviously on one of those boards! ;) <br />";
}


Since it is necessary to not use a title/frame in order to completely hide the block from boards you don't want it displayed on, you may wish to create your own Title/Frame via HTML in your content that is only displayed where you wanted to start with.
Title: Re: [Block] Only display "stuff" on certain boards
Post by: Tanix on January 27, 2007, 01:25:14 AM
Thank you very much! That's exactly what I needed, including not showing either title or frame.