How to display latest threads in HTML/PHP page ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Suri.CMS
    Senior Member
    • Apr 2008
    • 276

    How to display latest threads in HTML/PHP page ?

    Hi All,
    I have the vBulletin 3.7.1 forum installed in /forum folder.

    And I want to display the latest 10 threads from my forum in the home page (index.html / index.php)

    How can I do that ?

    Please explain in detail, as I am not really a techie :-)

    Note: I am not interested in using vbAdvanced for this. I just want to have a static HTML page as my home page and display the latest 10 forum threads there, so that the users will click on them and go to corresponding post in my forum.

    Thanks in advance...
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 74167

    #2
    Using RSS:


    Using Javascript:
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API

    Comment

    • Suri.CMS
      Senior Member
      • Apr 2008
      • 276

      #3
      Which method is better ?
      Any specific adv and disadv I should be aware of ?

      Comment

      • briansol
        Senior Member
        • Apr 2006
        • 674
        • 3.6.x

        #4
        Neither. the best solution is to include the config file an query your database directly from the homepage.

        Comment

        • Suri.CMS
          Senior Member
          • Apr 2008
          • 276

          #5
          Neither.
          Can you please tell me why those methods are not preferred ? I mean, any specific disadv ?

          the best solution is to include the config file an query your database directly from the homepage.
          If you don't mind, can you please explain how to do that ? (Or at least point to a tutorial to do that...)

          Comment

          • ~kev~
            Senior Member
            • Mar 2007
            • 213
            • 3.8.x

            #6
            Originally posted by Suri.CMS
            Which method is better ?
            Any specific adv and disadv I should be aware of ?
            As I stated over on digitalpoint, use the external data provider.

            In the script you put on your site you can specify what forum sections to pull the post from and how many post to pull.

            I have been using the external data provider for over 6 months on 3 portal sites, pulling data from several different forum sections. Everything has been working fine and with no problems. 2 of the html sites were migrated to wordpress sites and the data provider was disabled on those 2 sites.

            As for the RSS method, I have not used it. But I am going to guess that it is not as flexible as the external data provider and the javascript. With the javascript, you can set the exact forum ID you want the post to come from and how many post. So if you only want post coming from forum IDs 5,6,7 and 8 - that is what you set it to.

            In the external data provider you can set cut off limits to reduce the load on the server:
            Maximum External Records
            Cache Lifespan
            Thread Cutoff
            All of those can be set to increase/decrease the server load.

            So if your external site gets a lot of traffic, you can change the settings in the data provider to reduce the load on the server.
            Last edited by ~kev~; Thu 24 Jul '08, 1:49pm.
            survival gear forum

            Comment

            • Suri.CMS
              Senior Member
              • Apr 2008
              • 276

              #7
              use the external data provider.
              Yes, I used JavaScript method and it's working fine.

              Comment

              • Nick
                Senior Member
                • Feb 2008
                • 3507
                • 3.8.x

                #8
                Code:
                <!-- show latest active threads -->
                <table>
                <tbody>
                <tr>
                <td>
                
                <b>Latest Active Threads</b>
                </td>
                </tr>
                </tbody>
                <tbody>
                <tr>
                 
                <td width="100%">
                 
                <div>
                <script type="text/javascript" src="http://www.[COLOR=Red]YOURSITE.COM[/COLOR]/external.php?forumids=49,71,11,78,12,14,13,79&type=js"></script> 
                <script language="" type="text/javascript">
                <!--
                for (x = 0; x < [B][COLOR=Blue]15[/COLOR][/B]; x++)
                {
                document.writeln("<a href=\"http://www.[COLOR=Red]YOURSITE.COM[/COLOR]/showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <br>(Posted By: "+threads[x].poster+")<br><br />");
                }
                //-->
                </script></div>
                 
                </td>
                
                </tr>
                Replace the red text accordingly, and replace the blue number to the number of threads you wish to be displayed.
                Regards,
                Nick

                Comment

                • Suri.CMS
                  Senior Member
                  • Apr 2008
                  • 276

                  #9
                  Replace the red text accordingly, and replace the blue number to the number of threads you wish to be displayed.
                  Thank You.

                  I did the same thing for my site.

                  Comment

                  • myandy99
                    New Member
                    • Jun 2008
                    • 1

                    #10
                    I am trying to use this code in my tpl file but I ended up getting smarty error. What am I missing?

                    Fatal error: Smarty error: [in pages/homepage.tpl line 158]: syntax error: unrecognized tag: document.writeln(""+threads[x].title+"
                    (Posted By: "+threads[x].poster+")

                    "); (Smarty_Compiler.class.php, line 439) in /home/fetest/public_html/smarty/Smarty.class.php on line 1095

                    Comment

                    • Nick
                      Senior Member
                      • Feb 2008
                      • 3507
                      • 3.8.x

                      #11
                      Originally posted by myandy99
                      I am trying to use this code in my tpl file but I ended up getting smarty error. What am I missing?

                      Fatal error: Smarty error: [in pages/homepage.tpl line 158]: syntax error: unrecognized tag: document.writeln(""+threads[x].title+"
                      (Posted By: "+threads[x].poster+")

                      "); (Smarty_Compiler.class.php, line 439) in /home/fetest/public_html/smarty/Smarty.class.php on line 1095
                      Please start your own support thread.
                      Regards,
                      Nick

                      Comment

                      • peleh
                        New Member
                        • May 2009
                        • 21
                        • 3.8.x

                        #12
                        Originally posted by Nick
                        Code:
                        <!-- show latest active threads -->
                        <table>
                        <tbody>
                        <tr>
                        <td>
                        
                        <b>Latest Active Threads</b>
                        </td>
                        </tr>
                        </tbody>
                        <tbody>
                        <tr>
                         
                        <td width="100%">
                         
                        <div>
                        <script type="text/javascript" src="http://www.[COLOR=Red]YOURSITE.COM[/COLOR]/external.php?forumids=49,71,11,78,12,14,13,79&type=js"></script> 
                        <script language="" type="text/javascript">
                        <!--
                        for (x = 0; x < [B][COLOR=Blue]15[/COLOR][/B]; x++)
                        {
                        document.writeln("<a href=\"http://www.[COLOR=Red]YOURSITE.COM[/COLOR]/showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <br>(Posted By: "+threads[x].poster+")<br><br />");
                        }
                        //-->
                        </script></div>
                         
                        </td>
                        
                        </tr>
                        Replace the red text accordingly, and replace the blue number to the number of threads you wish to be displayed.
                        Thanks, it worked on my vb3.8.2, but one thing, it was YOURSITE.com/FORUM/showthread...

                        About the code, does anybody know if its possible to do the same thing, but for forum posts? Another usefull thing is if its possible to limit the line caracters with some kind of excerpt.
                        Last edited by peleh; Wed 20 May '09, 6:43pm.

                        Comment

                        • Nick
                          Senior Member
                          • Feb 2008
                          • 3507
                          • 3.8.x

                          #13
                          Originally posted by peleh
                          Thanks, it worked on my vb3.8.2, but one thing, it was YOURSITE.com/FORUM/showthread...

                          About the code, does anybody know if its possible to do the same thing, but for forum posts? Another usefull thing is if its possible to limit the line caracters with some kind of excerpt.
                          You cannot do it with individual posts, as vBulletin doesn't publish a feed for posts - only recent threads. It's something I've posted in the Suggestions forum before, though.
                          Regards,
                          Nick

                          Comment

                          • Drummerworld
                            New Member
                            • Sep 2007
                            • 2

                            #14
                            I managed now to bring it to work.

                            But:
                            1. I don't get, how to make opening a new page (blank).
                            Because i want to open a new page, when someone clicks on one of the threads.

                            2. it seems to me, that it doesn't show the newest threads, opposed the ones when clicking new posts in the forum. Seem to stay the same old ones?


                            Can you help me with this - hopefully correcting my code - thank you so much

                            Here:



                            the forum:



                            sourcecode:

                            <!-- show latest active threads --></p>
                            <table>
                            <tbody>
                            <tr>
                            <td width="300">
                            <p><span class="castibio12">Latest Active Threads in the Discussion Forum:</span></p>
                            </td>
                            </tr>
                            </tbody>
                            <tbody>
                            <tr>
                            <td width="300">
                            <div>
                            <p><span class="castibio11grau">
                            <script type="text/javascript" src="http://www.drummerworld.com/forums/external.php?forumids=3, 4, 8, 9, 6, 26, 25&type=js"></script>
                            <script type="text/javascript" language="">
                            <!--
                            for (x = 0; x < 8; x++)
                            {
                            document.writeln("<a href=\"http://www.drummerworld.com/forums/showthread.php?t="+threads[x].threadid+"\">"+threads[x].title+"</a> <br>(Posted By: "+threads[x].poster+")<br> <br />");
                            }
                            //-->
                            </script>
                            Last edited by Drummerworld; Thu 16 Jul '09, 3:51am.

                            Comment

                            • Nick
                              Senior Member
                              • Feb 2008
                              • 3507
                              • 3.8.x

                              #15
                              1. Change this section (make the addition in blue):

                              Code:
                              {
                              document.writeln("<a href=\"http://www.drummerworld.com/forums/showthread.php?t="+threads[x].threadid+"\" [COLOR=Blue][B]target="_blank"[/B][/COLOR]>"+threads[x].title+"</a> <br>(Posted By: "+threads[x].poster+")<br> <br />");
                              }
                              I didn't test it but that might work.

                              2. I just checked yours and it seems to work fine. Note that it takes a bit of time to update, as it isn't instant.
                              Regards,
                              Nick

                              Comment

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