Announcement

Collapse
No announcement yet.

How to use external.php?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Forum] How to use external.php?

    The 3.x manual (because there's no 4.x manual, despite the fact that we've paid for this software) gives an example of using the javascript switch for external.php and generating a "latest threads" block to insert into an external web page. However, it doesn't really describe all of the parameters we can use, and some of the ones given in 3.x threads don't seem to exist.

    The 3.x example using the RSS switch doesn't seem to show the author's name in recent versions, but it does show the body text of the post. The JS examples show the author's name but there is no functionality to show the body text.

    Is there a single, comprehensive description of how we can use this file with XML, RSS, RSS2, and JS? URL parameters, variables returned, everything? The standard RSS page works well but that is a complete web page; some of us just want to insert a customized version of that info into a different page and the examples don't work completely or only show one specific configuration.

    Here are the most commonly cited examples, from four+ years ago:

    [HowTo] Display your latest threads on an external page using an RSS2 feed
    [HowTo] Display your latest threads on an external page using an XML feed
    [HowTo] Display your latest threads on an external page using an RSS feed
    My VB forum: BMWRA

  • #2
    BTW I tested those three:

    XML - title, author, date/time
    RSS - title, forum name, author, date/time
    RSS2 - title, date/time, [author name asked for but doesn't appear], text preview
    RSS2 feed page gives title, date/time, text preview [no author name]

    I have to believe there's a way to simply get all of the fields with any stream method. None of these gives both the author and the preview.
    My VB forum: BMWRA

    Comment


    • #3
      I'm trying to figure out how to do something similar. I'd like to embed the blog system into an external php document, but I'm having a lot of trouble finding the documentation for this. Most specifically, utilizing the features which can be enabled from the AdminCP -> Options -> External Data Provider

      Comment


      • #4
        I've started to map out the field assignments in that file. It shouldn't be too hard to add the ones you want, or reference others that are already there. I don't think this is 100% accurate, but at least it shows my approach:
        Code:
        arguments:
        =============
        type (JS, XML, RSS, RSS1, RSS2)
        lastpost
        nohtml (RSS1 and RSS2 only)
        fulldesc
        count
        forumid or forumsids
        
        
        fields:
        ===============
        thread.threadid
        thread.title
        thread.prefixid
        post.attach
        if lastpost:
            thread.lastposter as postusername - author of last post
            thread.lastpost AS dateline
        else
            thread.postusername
            thread.dateline
        
        forum.forumid
        post.pagetext as message
        post.postid
        
        
        JS sends:
        ================
        this.threadid = threadid;
        this.title = title;
        this.poster = poster;
        this.threaddate = threaddate;
        this.threadtime = threadtime;
        
        Script looks for threads.threadid, title, poster
        
        
        XML sends:
        ============
        $xml->add_group('thread', array('id' => $thread['threadid']));
        $xml->add_tag('title', $thread['prefix_plain'] . unhtmlspecialchars($thread['title']));
        $xml->add_tag('author', unhtmlspecialchars($thread['postusername']));
        $xml->add_tag('date', vbdate($vbulletin->options['dateformat'], $thread['dateline']));
        $xml->add_tag('time', vbdate($vbulletin->options['timeformat'], $thread['dateline']));
        
        Script looks for title, author, date, time,
        
        
        RSS:
        ==============
        $xml->add_group('channel');
            $xml->add_tag('title', $rsstitle);
            $xml->add_tag('link', $vbulletin->options['bburl'] . '/', array(), false, true);
            $xml->add_tag('description', $description);
            $xml->add_tag('language', vB_Template_Runtime::fetchStyleVar('languagecode'));
            $xml->add_group('image');
                $xml->add_tag('url', $rssicon);
                $xml->add_tag('title', $rsstitle);
                $xml->add_tag('link', $vbulletin->options['bburl'] . '/', array(), false, true);
        
        Script loks for title, description, link
        
        
        RSS1:
        ===========
        $xml->add_group('channel', array(
            $xml->add_tag('title', $rsstitle);
            $xml->add_tag('link', $vbulletin->options['bburl'] . '/', array(), false, true);
            $xml->add_tag('description', $description);
            $xml->add_tag('syn:updatePeriod', $updateperiod);
            $xml->add_tag('syn:updateFrequency', $updatefrequency);
            $xml->add_tag('syn:updateBase', '1970-01-01T00:00Z');
            $xml->add_tag('dc:language', vB_Template_Runtime::fetchStyleVar('languagecode'));
            $xml->add_tag('dc:creator', 'vBulletin');
            $xml->add_tag('dc:date', gmdate('Y-m-d\TH:i:s') . 'Z');
            $xml->add_group('items');
                $xml->add_group('rdf:Seq');
                    $xml->add_tag('rdf:li', '', array('rdf:resource' => $vbulletin->options['bburl'] . '/'));
            $xml->add_group('image');
                $xml->add_tag('url', $rssicon);
                $xml->add_tag('title', $rsstitle);
                $xml->add_tag('link', $vbulletin->options['bburl'] . '/', array(), false, true);
        
        
        RSS2:
        ==========
        $xml->add_group('channel');
            $xml->add_tag('title', $rsstitle);
            $xml->add_tag('link', $vbulletin->options['bburl'] . '/', array(), false, true);
            $xml->add_tag('description', $description);
            $xml->add_tag('language', vB_Template_Runtime::fetchStyleVar('languagecode'));
            $xml->add_tag('lastBuildDate', gmdate('D, d M Y H:i:s') . ' GMT');
            #$xml->add_tag('pubDate', gmdate('D, d M Y H:i:s') . ' GMT');
            $xml->add_tag('generator', 'vBulletin');
            $xml->add_tag('ttl', $externalcache);
            $xml->add_group('image');
                $xml->add_tag('url', $rssicon);
                $xml->add_tag('title', $rsstitle);
                $xml->add_tag('link', $vbulletin->options['bburl'] . '/', array(), false, true);
        
        Script looks for title, description, link, pubdate, author.
        Isn't this great? Open-source type support, for the low low price of $175.
        My VB forum: BMWRA

        Comment


        • #5
          Well done. Many will thank you.

          It's a little over my head, I'd like to see a few examples if someone's in the giving spirit...
          -Andy.
          http://www.checkcheckonetwo.com
          http://www.mindplacesupport.com

          Comment


          • #6
            Originally posted by TheJordan View Post
            I'd like to embed the blog system into an external php document, but I'm having a lot of trouble finding the documentation for this. Most specifically, utilizing the features which can be enabled from the AdminCP -> Options -> External Data Provider
            The CMS might be different but basically that page in the Forum ACP only turns on the different feed types. At that point it's up to you to embed the right code somewhere to pull from that feed. I don't really know the difference between RSS, RSS1 and RSS2; I just want to be able to embed stuff with the most flexibility possible.

            So for example I turn on the Javascript feed in the ACP and then embed this in the destination page:

            Code:
            <script type="text/javascript" src="/forum/external.php?type=js&lastpost=1&forumid=27"></script>
            <script type="text/javascript">
            <!-- Start
            for(x = 0; x < 6; x++)
            { 
            document.writeln("<p><a href=\"/forum/showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a><br><span class=\"copytext\"> (posted by <i>"+threads[x].poster+")</i></span></p>");
            }
            //-->
            </script>
            ...and I get a list of six threads, ordered by most recent, from forum #27. But this is only one example; I'm trying to build the complete picture. The examples I listed at the beginning of this thread do the same thing for XML, RSS and RSS2.

            Obviously you can rewrite the output line to style the fields with DIVs, list elements, table cells, etc.
            My VB forum: BMWRA

            Comment


            • #7
              any news? i also search for a new external.php on vB 4.x to include my review pages. on there i use the username from board.....

              Comment


              • #8
                would just like to say thanks Anton for this thread, believe it or not its actually really helped me out with my site

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...
                X