The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
How to create a Ajax Sidebar with Recent Posts Details »» | |||||||||||||||||||||||||||
How to create a Ajax Sidebar with Recent Posts
Developer Last Online: Dec 2006
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> 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(); Code:
setInterval('updateSidebar()', 60000 * 1); // Update every minute setInterval('updateSidebar()', 60000 * 3); // Update every 3 minutes For a preview and more discussion: http://www.youngcoders.com/showthrea...288&styleid=19 Show Your Support
|
Comments |
#12
|
||||
|
||||
Awesome!
|
#13
|
|||
|
|||
Quote:
|
#14
|
||||
|
||||
The full bar would be ok though. I know it`s easy to replicate
|
#15
|
|||
|
|||
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? |
#16
|
||||
|
||||
A link to your site maybe ?
|
#17
|
|||
|
|||
Quote:
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:
Quote:
|
#18
|
||||
|
||||
All you need is to add a left/right comun code, and add the code in there. That`s it.
|
#19
|
|||
|
|||
Where do we add it?
which template?? |
#20
|
||||
|
||||
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 . |
#21
|
|||
|
|||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|