Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
How to show last 20 topics on other webpages
I have already installed Vanilla Forums on my website.
Now , I want to show last 20 topics on my homepage.
I don't know much of API . Just need some working codes.
Now , I want to show last 20 topics on my homepage.
I don't know much of API . Just need some working codes.
Tagged:
0
Best Answer
-
Todd Vanilla StaffI'm going to help you get started with some javascript that we've done for a client.
Please note that this script uses jQuery so you'll need to include that in your page as well. It is a very common library and should work. You should really know javascript and jQuery a little bit or you'll be flying blind though.// Include this script where you want to embed the latest 20 discussions. // This script requires jQuery. document.write('<div id="vn_discussions_popular"></div>'); jQuery(document).ready(function($) { var url = 'http://yourforumhere.com/discussions.json?page=1-20&callback=?'; $.ajax({ url: url, dataType: 'json', success: function(data) { var foo = 'bar'; var result = ''; for(i in data.Discussions) { d = data.Discussions[i]; result += '<li><a href="'+d.Url+'">'+d.Name+'</a></li>'; } result = '<ul>'+result+'</ul>'; $('#vn_discussions_popular').html(result); } }); });
Notes
1. Notice that the url looks very similar to the url that your browse to when viewing the forum normally. The only difference is that it has a.json?page=1-20&callback=?
on the end. This is the API in action and you can call most urls that way.
2. If you want to figure out what kind of data is returned from the API I recommend getting the excellent JSONView Firefox extension. Once you've installed this you can copy that api url into your browser and have a look at what comes out. If you don't install JSONView you can still look at the url, but you will be prompted to download.1
Answers
Please note that this script uses jQuery so you'll need to include that in your page as well. It is a very common library and should work. You should really know javascript and jQuery a little bit or you'll be flying blind though. Notes
1. Notice that the url looks very similar to the url that your browse to when viewing the forum normally. The only difference is that it has a
.json?page=1-20&callback=?
on the end. This is the API in action and you can call most urls that way.2. If you want to figure out what kind of data is returned from the API I recommend getting the excellent JSONView Firefox extension. Once you've installed this you can copy that api url into your browser and have a look at what comes out. If you don't install JSONView you can still look at the url, but you will be prompted to download.
In this case it wouls solve that problem... :P
Then , How can I show more data like posters , posting date , topic view count?
http://ebay.fakjai.com/bbs/top20.php
I'm interested in showing the guests the title of the threadb ut force them to reginstr&login to read the contents (posts)...
Has anyone gotten this to work recently? I'd like to embed just the titles of the recent discussions into my website. I tried the method above but got this error:
I'm using Vanilla 2.1b2
bump...for some reason my comment didn't show up in the feed of new posts.
post the exact code you inserted and we might see where the syntax error is.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Line 3 was the one cited in the error