Hello,
Quick question here, but googling has so far not yielded any results. We run a website on which we have an SMF forum and some other stuff, like a blog, static pages and the like. We would like to be able to load the content (messages) in a given topic of our SMF forum and display them on another part of the website which is not part of the forum. Let's say we have the /smf/index.php?topic=12345 , we would like to be able to load the posts/messages from that topic and display them on any part of the site we would like. Does this make sense? Is there an API or anything that lets us do this?
Thanks,
Horowitz
We do have something like that, yes.
https://www.simplemachines.org/community/ssi_examples.php
https://wiki.simplemachines.org/smf/SSI_FAQ_Basic
https://wiki.simplemachines.org/smf/SSI_FAQ_Expert
Thanks for your swift reply!
A list of recent posts is not quite what I am looking for, unfortunately. I'll try to explain a bit better.
Let's say I have a topic in our SMF forum at www dot ourcoolwebbypage dot com/smf/index.php?topic=69893.0
In the topic, there are three messages from three users, something like this:
Member1
This is my awesome topic!
Hello guys!
Member2
Re: this is my awesome topic!
Nice topic!
Member3
Re: this is my awesome topic!
Yeah, I agree, nice topic!
What we are looking for is an API or mod or anything that enables us to load the messages (usernames, message contents, etc) from that particular topic and display them outside the forum, on another part of the site.
Something like, in our code:
getMessages({topicId: 69893})
returns either an array of messages, HTML, or anything else we can use to display the messages that have been posted in that particular topic anywhere we would like.
Is this possible?
Do take a closer look at the SSI_Examples. ;)
The Function list on the left side of it in particular.
I think you'll find out that it does a fair bit more than just show you your recent posts.
Quote from: Aleksi "Lex" Kilpinen on May 26, 2023, 11:31:10 AMDo take a closer look at the SSI_Examples. ;)
The Function list on the left side of it in particular.
I think you'll find out that it does a fair bit more than just show you your recent posts.
I have throughly read through that page, and I feel like I'm going a bit crazy :p Is it the
ssi_boardNews()
ssi_fetchPosts()
functions you are referring to? That's more like it, but they don't seem to do exactly what I want. It doesn't seem like I can give a specific topic ID to the ssi_fetchPosts() function, just an array of message ID:s, no? How would I get the post IDs that belong to a particular topic ID?
Or did you have some other functions in mind?
You just need to create the array (perhaps with a database query directly) and then you can use ssi_fetchposts.
You could code a simple php page that reads the selected messages from the messages table in the database and displays them.
use ssi_queryPosts
Warning - untested
<?php
require_once('SSI.php');
$gettopic='id_topic=1234';
$max_count=100;
$topic_posts=ssi_queryPosts($gettopic,null,$max_count,'m.id_msg DESC','array',false,false);
ssi_fetchPosts($topic_posts,false,'echo');
?>
alternatively, replace the echo in the fetchPosts and output the content in the format that you want....