Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Template Modifications
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
How to create a Ajax Sidebar with Recent Posts Details »»
How to create a Ajax Sidebar with Recent Posts
Version: 1.00, by Mauu Mauu is offline
Developer Last Online: Dec 2006 Show Printable Version Email this Page

Version: 3.6.0 Rating:
Released: 09-12-2006 Last Update: Never Installs: 21
Template Edits
Additional Files Is in Beta Stage  
No support by the author.

At YoungCoders, I recently wrote an ajax enabled recent posts widget, and I thought I would post it here. I do not recommended this for high traffic forums, as you'll be running a lot of queries.

I'm going to forget to check back here and update this with any changes. So, please see here, which is where I will maintain and try to provide support.

I) Setting up the Feed
1) First, you need the improved external.php file from vBulletin.org. The link is here: https://vborg.vbsupport.ru/showthrea...t=fps_external

2) This new external file lacks some of the documented features, and the feature we need is the latest posts (not latest threads). The attached file resolves that and may only be used if you have a valid vBulletin license. The reason we may not use the built-in one is because it does not have support for permissions and will therefore treat every user as a guest. Credit for fps_external.php goes to the original authors; my revision was trivial.

3) Upload fps_external.php into your forum directory.

II) Setting up the Ajax
1) Our threads are going to appear in an unordered list. So, let's setup our default list:
HTML Code:
  <ul id="latestthreads">
   <li>Please wait while the feed updates.</li>
  </ul>
We have to throw in the please wait to make our page validate and also to notify our users that we're fetching the feed.

2) You then need some JavaScript. I'm not going to document this as it's pretty self-explanatory:
Code:
/*
* Ajax sidebar for vBulletin.
* Depends: hacked fps_external.php
* Created for: www.youngcoders.com
*/


function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function updateSidebarResponse() {
    if(http.readyState == 4){
        var length = document.getElementById('latestthreads').getElementsByTagName('li').length;
        for (var y = 0; y < length; y++)
        { 
                document.getElementById('latestthreads').removeChild( document.getElementById('latestthreads').getElementsByTagName('li')[0] );
        }
        
        
        var response = http.responseXML.getElementsByTagName('source')[0].getElementsByTagName('thread');
        var length = response.length;
        for (var x = 0; x < length; x++)
        {
                var id = response[x].getAttribute('id');
                var title = response[x].getElementsByTagName('title')[0].childNodes[0].nodeValue;
                var author = response[x].getElementsByTagName('author')[0].childNodes[0].nodeValue;
                var when = response[x].getElementsByTagName('time')[0].childNodes[0].nodeValue;

                var top = document.createElement('div');
                var bottom = document.createElement('div');

                var option = document.createElement('li');
                var link = document.createElement('a');
                link.href = 'showthread.php?goto=newpost&t=' + id;
                link.appendChild(document.createTextNode(title));
                var by = document.createElement('small');
                by.appendChild(document.createTextNode(' by ' + author + ' at ' + when));

                option.appendChild(link);
                option.appendChild(by);

                document.getElementById('latestthreads').appendChild(option);
        }
    }
}

function updateSidebar() {
    http.open('get', 'fps_external.php?type=xml&qty=20&items=active');
    http.onreadystatechange = updateSidebarResponse;
    http.send(null);
}


updateSidebar();
The above code will fetch the sidebar just once. To make it update, you must have it run through intervals:
Code:
setInterval('updateSidebar()', 60000 * 1); // Update every minute
setInterval('updateSidebar()', 60000 * 3); // Update every 3 minutes
Terms of Use: For each site you deploy this on, you must tell one friend about YoungCoders.com

For a preview and more discussion: http://www.youngcoders.com/showthrea...288&styleid=19

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 09-16-2006, 12:08 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome!
Reply With Quote
  #13  
Old 09-17-2006, 02:19 PM
Kihon Kata Kihon Kata is offline
 
Join Date: Nov 2003
Posts: 763
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
I do not recommended this for high traffic forums, as you'll be running a lot of queries.
I'm out
Reply With Quote
  #14  
Old 10-21-2006, 10:10 PM
t3nt3tion's Avatar
t3nt3tion t3nt3tion is offline
 
Join Date: Aug 2005
Location: 3rd Planet from the Sun
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The full bar would be ok though. I know it`s easy to replicate
Reply With Quote
  #15  
Old 10-22-2006, 11:04 PM
Kungfu Kungfu is offline
 
Join Date: Dec 2005
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any idea why nothing is showing up?

i do fps_external.php?type=xml&qty=1&items=active
just from the browser and its blank and im not sure why. any ideas?
Reply With Quote
  #16  
Old 10-23-2006, 04:21 AM
t3nt3tion's Avatar
t3nt3tion t3nt3tion is offline
 
Join Date: Aug 2005
Location: 3rd Planet from the Sun
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A link to your site maybe ?
Reply With Quote
  #17  
Old 11-03-2006, 07:02 AM
Illustrious Illustrious is offline
 
Join Date: Dec 2005
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mauu
It really can't get much simpler: upload patched fps_external, stick HTML in, stick JavaScript in, done. Granted, basic web-design knowledge is required.
The problem is where do you "stick HTML/JavaScript in" and how do you link this to the sidebar. A guide does that, explain what you have to do in reasonably simple terms so that people who are unable to do it without the guide can. One way you could go about is write up the guide so that you give one generic example solution of how to install it.

Judging by the replies on your own website, it seems like a lot of others are confused.

For example, I can easily point out:

Quote:
II) Setting up the Ajax
1) Our threads are going to appear in an unordered list. So, let's setup our default list:
Set up the default list where?

Quote:
2) You then need some JavaScript. I'm not going to document this as it's pretty self-explanatory:
And where does this javascript go?
Reply With Quote
  #18  
Old 11-03-2006, 02:35 PM
t3nt3tion's Avatar
t3nt3tion t3nt3tion is offline
 
Join Date: Aug 2005
Location: 3rd Planet from the Sun
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All you need is to add a left/right comun code, and add the code in there. That`s it.
Reply With Quote
  #19  
Old 11-24-2006, 02:17 AM
AMD_Warrior AMD_Warrior is offline
 
Join Date: Jul 2006
Location: NY
Posts: 58
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where do we add it?
which template??
Reply With Quote
  #20  
Old 11-24-2006, 03:36 PM
ManagerJosh's Avatar
ManagerJosh ManagerJosh is offline
 
Join Date: Feb 2002
Posts: 348
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

While I'm no coder, I took a look at the code and it appears you put it in the header template. That's my best guess.

Either way, I'm echoing the same problems with this template release and that the installation is rather vague. Moreso, you didn't release any code for your AJAX sidebar I'd like to point out .
Reply With Quote
  #21  
Old 11-25-2006, 04:38 PM
fatwillie fatwillie is offline
 
Join Date: Oct 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
How to create a Ajax Sidebar
I don't see any ajax code nor do I see sidebar code...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04485 seconds
  • Memory Usage 2,316KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)bbcode_html
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete