1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting XML/RSS while board is "closed"

Discussion in 'XenForo Development Discussions' started by Adam K M, Jun 25, 2015.

  1. Adam K M

    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
    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_handleCURLOPT_URL,$url);
            
    curl_setopt($curl_handleCURLOPT_CONNECTTIMEOUT2);
            
    curl_setopt($curl_handleCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($curl_handleCURLOPT_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>
    upload_2015-6-25_9-52-5.png


     

Share This Page