[TIP] $variable for is_board_index.

Started by darrenbeige, September 09, 2009, 10:59:56 AM

Previous topic - Next topic

darrenbeige

If you're like me and like messing around with SMF a lot, its handy to have a variable for is_board_index available. Strangely, SMF doesn't seem to automatically set this variable, so I hand-coded one in. Its pretty simple.

In index.php find // Action and board are both empty... BoardIndex!
if (empty($board) && empty($topic))
{
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';
}


and replace with // Action and board are both empty... BoardIndex!
if (empty($board) && empty($topic))
{
$settings['is_board_index'] = true;
require_once($sourcedir . '/BoardIndex.php');
return 'BoardIndex';
}


I've added mine to $settings, but if you want to be a bit more semantic, you need to globalize $context inside smf_main before adding $context['is_board_index'] instead of $settings['is_board_index'].

Marcus Forsberg


Arantor


darrenbeige

I'm surprised there isn't this variable (or a similar one) set in the default SMF installation. They have all manner of variables set in $context that I never use, but [is_board_index] just doesn't exist. Its quite strange.

Arantor

Everything that's in $context is there because it is used by something, AFAIK.

darrenbeige

Oh right. That makes sense. Personally, I thought the $context variable was more for developers to use, as most of the time, $user_info exists that contains most of $context anyway.

Arantor

$user_info is for user-specific stuff (or should be) - $context contains a lot of generic stuff (and a subset of $user_info sometimes too)

Advertisement: