Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: TheGamer on June 25, 2006, 04:02:57 PM

Title: Simple SSI Question
Post by: TheGamer on June 25, 2006, 04:02:57 PM
<?php ssi_recentTopics(); ?>

How do I make that only apply to one board (e.g. only display recent topics from board 85.0)

Thanks!
Title: Re: Simple SSI Question
Post by: Elmacik on June 25, 2006, 04:09:36 PM
You can use it like that:

<?php ssi_recentTopics('5', array('1''2''3')); ?>


Say you have 4 boards.. With the code above, you have restricted the recent topics to board 4, because you excluded the first three ones.
Number 5 in the code means the number of recent topics will be displayed.

And also take a look at:
Basic SSI FAQ (http://www.simplemachines.org/community/index.php?topic=12936.0)
Advanced SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13016.0)
Expert SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13205.0)
Title: Re: Simple SSI Question
Post by: TheGamer on June 25, 2006, 04:13:14 PM
Thanks for the prompt reply, but I'm not sure I understand what you're saying.
So if I want it to display only recent topics from the board 85.0, what code do I need to use?

<?php ssi_recentTopics('85.0', array('1', '2', '3')); ?>


?
Title: Re: Simple SSI Question
Post by: Elmacik on June 25, 2006, 04:20:42 PM
Unfortunately, ssi_recentTopics does not let us specify the board to include. In contrast, it lets us to exclude the boards we dont want while displaying the recent topics.
So if you want to show recent topics only from board 85, I suggest you to use board news like this:
<?php ssi_boardNews('85'); ?>
This will display the recent topics in the board 85.

If you still want to use recentTopics; you can use it this way:
<?php ssi_recentTopics('1''2''3''4''5''6''7''8''9''10''11''12''13'); ?>
Those go till 85.. This means, recentTopics function will exclude the boards 1,2,3,4,5,6,7,8,9,10,11,12,13.. so on.
Title: Re: Simple SSI Question
Post by: Thantos on June 25, 2006, 04:43:58 PM
Well personally I'd wrap it up in a function.


function ssi_recentTopicsFromBoards($from_boards, $num_recent = 8, $output_method = 'echo')
{
global $context, $db_prefix, $user_info;
if ( !isset($context['boards_available']) )
{
// Get a list of the boards they can see
$context['boards_available'] = array();
$request = db_query("
SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE $user_info[query_see_board]", __FILE__, __LINE__);
while ( $row = mysql_fetch_assoc($request) )
$context['boards_available'][] = (int) $row['ID_BOARD'];
mysql_free_result($request);
}

if ( !is_array($from_boards) )
$from_boards = array ( $from_boards );

// Make a copy of the board list so we can remove the ones we do want to see
$dontshow = $context['boards_available'];
foreach($dontshow AS $index => $id)
if ( in_array($id, $from_boards) )
unset($dontshow[$index]);
return ssi_recentTopics($num_recent, $dontshow, $output_method);
}


Note the above is not tested.
Title: Re: Simple SSI Question
Post by: duck1 on December 05, 2006, 12:49:36 PM
Well i can say this:
Put the code from thantos code into ssi.php and it works perfectly..
But how to remove the user check and just list newest from a forum with guest access ?
can it be modefied to this ?


Title: Re: Simple SSI Question
Post by: Sessizlik Senfonisi on December 24, 2006, 06:26:34 PM
i want to use it...

But i am using MK_PortaL

My Block Code:

<?php

$content
=implode(""file

("http://localhost/111/forum/SSI.php?ssi_function=recentTopics"));

?>


How do i add ssi_recentTopicsFromBoards

<?php

$content
=implode(""file

("http://localhost/111/forum/SSI.php?ssi_function=[recentTopicsFromBoards"));

?>


it s not working :(