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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,031
  • Total Topics: 21,335
  • Online today: 321
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

HELP! Need a quick hack for block "access choices"

Started by peterstaley, February 14, 2007, 01:50:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

peterstaley

Ichbin -- I need a slight revision on this coding, and don't know how to do it.  Instead of excluding one board, I need to exclude two (and possibly 3 or more, in the future).

How would I change "if($context['current_board'] != X)" so that it would exclude boards X, Y and Z?

Peter

Quote from: IchBinâ,,¢ on February 14, 2007, 03:05:08 PM
Put this in a block. (change X to the board ID you need)

if($context['current_board'] != X)
{

// All your code for the block goes in between these two brackets.

}



IchBin

Change the boardlist array to have the board ID's that you need.
$boardlist = array(2,5,7);

if (intersect_array($context['current_board'], $boardlist))
{

    echo 'all your code in between the two single quotes';

}

peterstaley

Hmm.  I can't seem to get this to work.  Remember, I'm PHP dumb.

I tried this coding, and it broke the index page (everything below the center block disappeared):
$boardlist = array(25,26);

if (intersect_array($context['current_board'], $boardlist))
{

    include('welcome.htm');

}


It showed the block, but had the following error showing inside it:

Fatal error: Call to undefined function intersect_array() in /[mysite]/Themes/default/TPortalBlocks.template.php(35) : eval()'d code on line 3

IchBin

oops.... intersect_array should be array_intersect :D

peterstaley

that got rid of the error message, but now I've got 2 problems:

1)  the block now appears above ALL my boards, including boards 25 and 26 -- the two this coding should prevent the block from appearing.

2)  the block is empty except for its title, so for some reason the "include('welcome.htm');" coding above isn't working.  This is true regardless of which board I'm in.

Any help would be much appreciated.

Peter

IchBin

Been a while since i've used arrays in PHP. Maybe $boardlist = array(25,26); needs to be $boardlist[] = array(25,26); instead.

peterstaley

Nope -- unfortunately, that didn't seem to change anything.  Still the same two issues -- block shows up above all boards, and doesn't show the include (only shows the block with its headline).

Peter

IchBin

Don't know where my mind was when I did this. This should work. I had the array check backwards.
$boardlist[] = array(25,26);

if (intersect_array($boardlist, $context['current_board'] ))
{

    include('welcome.htm');

}

peterstaley

That one got me back to the same error message, so I used array_intersect instead of intersect_array, but still no luck.  It's still showing on all boards, and still doesn't include the coding from welcome.htm.

peterstaley

does array_intersect need to be in round brackets?

should I try this instead...

if array_intersect($boardlist, $context['current_board'] )

This website is proudly hosted on Crocweb Cloud Website Hosting.