News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

how do i get a a board tree in an external script?

Started by plainas, April 03, 2008, 08:49:45 AM

Previous topic - Next topic

plainas

That's the question.
I want the structure containing all the boards in an external script.
I need tips on this as i don't know SMF source so well.

Is there any variable that already holds that structure?
I belive calling getBoardIndex($boardIndexOptions) would return what i want, but i am not sure of which parameters i should pass to it nor if its even available by including SSI.php

Can anybody five me a few tips in here?

Spaceman-Spiff

You can try including SSI.php and Sources/BoardIndex.php, then calling the BoardIndex() function.

This will display the exact same thing on your forum index. If what you need is just a simple/short listing, try take a look at the Sitemap mod, or you may have to create your own custom script.

plainas

#2
Thanks spaceman.

The sitemap mod use this code:



function BoardDisplay() {

global $context$db_prefix$user_info;

// Set the right sub template
$context['sub_template'] = 'Boards';
$context['sitemap']['collapsible'] = array();

// Get our information from the database
$request db_query("
SELECT b.ID_BOARD, b.ID_PARENT, b.childLevel, b.name, b.description, b.numTopics, b.numPosts
FROM 
{$db_prefix}boards as b
WHERE 
$user_info[query_see_board]
ORDER BY b.boardOrder"
__FILE____LINE__);

// And assign it to an array
while ($row mysql_fetch_assoc($request))
{
$context['sitemap']['board'][$row['ID_BOARD']] = array(
'id' => $row['ID_BOARD'],
'level' => $row['childLevel'],
'has_children' => false,
'name' => $row['name'],
'description' => $row['description'],
'numt' => $row['numTopics'],
'nump' => $row['numPosts'],
);

// If we are a child, and the first at that, let the parent know that at least one of us exists!
if(!empty($row['childLevel']) && $row['childLevel'] == '1') {
$context['sitemap']['board'][$row['ID_PARENT']]['has_children'] = true;
$context['sitemap']['collapsible'] = $context['sitemap']['collapsible'] + array($row['ID_PARENT'] => $row['ID_PARENT']);

}
}

$context['sitemap']['collapsible'] = '\'parent' implode('\', \'parent'$context['sitemap']['collapsible']) . '\'';

// Free the result.
mysql_free_result($request);
}


Is there anything that is going to change in smf 2.0 that makes this code incompatible?
This code looks pretty neat an clean, i wouldn't mind using it.

Advertisement: