Adam K M
Active member
Hello,
I'm currently working on some custom resources for a forum, currently in the Options -> Board Active, I have turned the forum off, as I don't want users coming and seeing incomplete parts of the new forum.
On the homepage (a regular page node), I would like to show the content from the most recent thread from our news and announcements forum. I decided the easiest and quickest way to do so would be by using XenForo's built-in RSS feeds. However, when the server fetches the post content via php (by <xen:callback>) with a custom plugin, the returned data is not the xml of the forum, but rather, a message saying that the board is currently closed.
How would I go about getting the most recent post to show up? Fixing the XML loader to view board options is probably the quickest, but I don't mind using another method via templates.
Here's the current code:
Add-on
Page Code

I'm currently working on some custom resources for a forum, currently in the Options -> Board Active, I have turned the forum off, as I don't want users coming and seeing incomplete parts of the new forum.
On the homepage (a regular page node), I would like to show the content from the most recent thread from our news and announcements forum. I decided the easiest and quickest way to do so would be by using XenForo's built-in RSS feeds. However, when the server fetches the post content via php (by <xen:callback>) with a custom plugin, the returned data is not the xml of the forum, but rather, a message saying that the board is currently closed.
How would I go about getting the most recent post to show up? Fixing the XML loader to view board options is probably the quickest, but I don't mind using another method via templates.
Here's the current code:
Add-on
PHP:
class SCC_Main_miscFuncs {
public static function printMostRecentPost() {
$rssUrl = func_get_arg(1);
$xml = simplexml_load_string(self::returnContents($rssUrl));
//var_dump($xml->message);
echo $xml->message;
}
public static function returnContents($url){
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,$url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'ShortCut Central');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
return $query;
}
}
Page Code
HTML:
<xen:callback class="SCC_Main_miscFuncs"
method="printMostRecentPost"
params="{$xenOptions.boardUrl}/{xen:link 'forums', {xen:array 'node_id=4'}}index.rss">
</xen:callback>
