Re: SSI - showing an entire 'thread' with posts [PHP] ?

mercredi 30 avril 2014

That's sort of what I meant but not the way to do it. current() only returns one element of the array so you're making multiple calls to ssi_fetchPosts(). You should build the array first, then use that as the parameter in ssi_fetchPosts() as such:

$post_info = ssi_fetchPosts($post_id_array, false, 'array');


However, simpler yet, the following is a re-write of the ssi_fetchPosts() function which will return all posts in a topic. Add this to the end of SSI.php before the closing ?>.


function ssi_fetchTopic($topic_id, $override_permissions = false, $output_method = 'echo')

{

global $user_info, $modSettings;

$query_where = '

m.id_topic = {int:topic}' . ($override_permissions ? '' : '

AND {query_wanna_see_board}') . ($modSettings['postmod_active'] ? '

AND m.approved = {int:is_approved}' : '');

$query_where_params = array(

'topic' => $topic_id,

'is_approved' => 1,

);


// Then make the query and dump the data.

return ssi_queryPosts($query_where, $query_where_params, '', 'm.id_msg ASC', $output_method);

}




Call it like so. Since it's an array you need to loop though each of the elements. Do change the first parameter to the id of your topic. $posts = ssi_fetchTopic(13, false, 'array');



foreach ($posts as $post_info)

echo '<h3>', $post_info['link'], '</h3>

<hr style="width: 65%; margin-left: 0;" />

<p>', $post_info['body'], '</p>';


Notice that I didn't use current(). For more info on outputting as an array. The second FAQ covers that. ssi_boardNews() is used as an example but the principle is the same.

[README] SSI FAQ's






0 commentaires:

Enregistrer un commentaire

 

Lorem

Ipsum

Dolor