Introduction   Getting Started   Upgrading   Function Reference   Changelog   Support and Feedback

get_topic_info

Usage: array get_topic_info (int topicid)
Purpose: Retrieves information on a topic.
Availability: IPB SDK 0.5

Returns information on topic topicid.

If the topic topicid does not exist FALSE will be returned.

Information will be returned in the following array structure:

Array (
      [tid] => 2
      [title] => Shoutbox
      [description] => Thread... thing
      [state] => open
      [posts] => 104
      [starter_id] => 1
      [start_date] => 1082968226
      [last_poster_id] => 2
      [last_post] => 1096389042
      [icon_id] => 0
      [starter_name] => Pita
      [last_poster_name] => khlo
      [poll_state] => 0
      [last_vote] => 0
      [views] => 484
      [forum_id] => 1
      [approved] => 1
      [author_mode] => 1
      [pinned] => 0
      [moved_to] =>
      [rating] =>
      [total_votes] => 0
      [topic_hasattach] => 0
      [topic_firstpost] => 2
      [topic_queuedposts] => 0
      [pid] => 2
      [append_edit] => 0
      [edit_time] =>
      [author_id] => 1
      [author_name] => Pita
      [use_sig] => 1
      [use_emo] => 1
      [ip_address] => 127.0.0.1
      [post_date] => 1082968226
      [post] => This is the shoutbox thread
      [queued] => 0
      [topic_id] => 2
      [post_title] =>
      [new_topic] => 1
      [edit_name] =>
      [post_parent] => 0
      [post_key] => 0
      [post_htmlstate] => 0
      [attach_id] =>
      [attach_hits] =>
      [attach_ext] =>
      [attach_location] =>
      [attach_file] =>
      [usedohtml] => 0
)

// Displays "There are 20 posts in topic 43"
$topicinfo = $SDK->get_topic_info("43");
echo "There are ".$topicinfo['posts']." posts in topic 43";

// Displays "Topic 43 was started by khlo"
$topicinfo = $SDK->get_topic_info("43");
echo "Topic 43 was started by ".$topicinfo['starter_name'];
See Also: get_post_info


User Contributed Notes

kalurak
It is important to catch and convert HTML-posts or topics:

<?
$topic = $SDK->get_topic_info($topicid);
$viewtopic = $topic['post'];
$htmlstate = $topic['post_htmlstate'];
if($htmlstate == 1 || $htmlstate == 2) {
$viewtopic = str_replace('<', '<', $viewtopic);
$viewtopic = str_replace('>', '>', $viewtopic);
}
if($htmlstate == 2) {
$viewtopic = str_replace('\n', '<br>', $viewtopic);
}

echo $viewtopic;
?>

kalurak
*argh* this form converted the & gt; and $lt;

please replace
$viewtopic = str_replace('<', '<', $viewtopic);
$viewtopic = str_replace('>', '>', $viewtopic);

with
$viewtopic = str_replace('& lt;', '<', $viewtopic);
$viewtopic = str_replace('& gt;', '>', $viewtopic);

and erase the space between & and lt; or gt;

Documentation Generated at Sat, 16 Apr 2005 07:36:35 -0700
Find the latest version at http://ipbsdk.sourceforge.net