View Full Version : php mysql query to pull last x number of posts
gcombe74
03-12-2016, 10:54 PM
I migrated from phpbb3 to vbulletin.. and I used to pull the last 30 posts from my site by post id..
and oddly I can do that in vbulletin as well but only the posts that imported...
so the question is this..I was pulling by postid or lastpost... its easy to tell that vb5 has gone away from postid...
but is there query that I can run in vb5 to do this? can someone help me figure out how to reconstruct the url for pulling the last x number just php and mysql query?
Thanks
Replicant
03-13-2016, 02:43 AM
That won't be easy to do. All posts, threads, forums, categories, attachments, photos, galleries, private messages......you get the idea, are stored in the node table. Everything in vb5 is considered content. It is possible to do refining the query by contenttype, but may not be full proof. Might I ask what exactly you are trying to accomplish?
The reason you can still puul the last 30 by postid in vbulletin on imported posts is because your old post table still exists.
gcombe74
03-13-2016, 10:44 PM
That won't be easy to do. All posts, threads, forums, categories, attachments, photos, galleries, private messages......you get the idea, are stored in the node table. Everything in vb5 is considered content. It is possible to do refining the query by contenttype, but may not be full proof. Might I ask what exactly you are trying to accomplish?
The reason you can still puul the last 30 by postid in vbulletin on imported posts is because your old post table still exists.
just on my main site I like to list the last 30, but most of my forums are closed so RSS wont build them. so I was just wanting to pull the topic, date, person posting so people can see what is being taked about in a quick glance. in phpbb3 you can deterime what is built in RSS locked or not.
Replicant
03-14-2016, 01:14 AM
I use a search module with a custom search string in it that gives all the new threads, posts and comments in chronological order starting with the newest to the oldest. It works relatively bug free since version 5.1.5. Here is the basic version. I can help you tweak it for your needs. It also displays results based on permissions so if the user is logged in and has access to the closed forums, those new posts will be displayed for them to view.
search?searchJSON={"date":{"from":"1"},"type":["vBForum_Gallery","vBForum_Link","vBForum_Photo","vBForum_Poll","vBForum_Text","vBForum_Video"],"sort":{"relevance":"desc"},"view":"","exclude_type":["vBForum_PrivateMessage"]}
To use it, create a new page in site-builder and add the search module to the page. Edit the search properties in the advanced edit section and replace the search string with this one. Name the page and set the url to whatever you want such as /activity. Now when you navigate to /activity, you will see a page similar to the activity stream in vb4. You can adjust the "date"{"from":1 to however many days you wish to yield more or less results. This module can also be dropped onto a regular page or the front page if you want and will do the same thing. It will auto format for the size column you drop it in.
gcombe74
03-14-2016, 08:01 PM
that code worked well. thank you.
So answer me this.. what would have have to embed in my main site (outside the forum) to make it display it on web page outside my forum? I realize session info is needed just not sure how in VB5 if that can be or how to.
shimei
03-14-2016, 08:19 PM
that code worked well. thank you.
So answer me this.. what would have have to embed in my main site (outside the forum) to make it display it on web page outside my forum? I realize session info is needed just not sure how in VB5 if that can be or how to.
Just curious, if I am understanding you right..... Wouldn't a RSS feeder on the other site work to list all the newest posts from RSS on your Vb 5 site?
Replicant
03-15-2016, 12:53 AM
that code worked well. thank you.
So answer me this.. what would have have to embed in my main site (outside the forum) to make it display it on web page outside my forum? I realize session info is needed just not sure how in VB5 if that can be or how to.
This code can help you with that. For it to work, your cookie path has to be / in vb5. It will of course need other code, but this is the basis of viewing forum content outside the forums.
External Login Tutorial (http://www.vbulletin.com/forum/blogs/david-grove/4327147-how-to-log-into-vbulletin-from-an-external-script-on-your-website)
Just curious, if I am understanding you right..... Wouldn't a RSS feeder on the other site work to list all the newest posts from RSS on your Vb 5 site?
Nope, he wants his users with private forum access to be able to view the activity stream. The RSS only works for public forums.
IggyP
03-16-2016, 12:18 AM
ive tried this fix and some other things but still cannot get a basic display of recent content in the order it was updated....theres always a couple in the middle thats out of order...
the search modules are pretty confusing to start with in vb5 but then to not work idk what i can do but wait and pray they fix it:(
really all i want is one "topic view" style module with a list of latest topics, posts, and comments, then one "default style" module that includes all activity but pms....shouldn't be too hard right?
--------------- Added 1458114644 at 1458114644 ---------------
well...i kept messing with it....
this is the best string i found so far
{"last_visit":1,"type":["vBForum_Gallery","vBForum_Link","vBForum_Poll","vBForum_Text","vBForum_Video"],"channel":["1"],"sort":{"lastcontent":"desc"},"view":"topic","exclude_type":["vBForum_PrivateMessage"]}
i think my confusion may be a bug for if i add photo content, it basically breaks....takes out things that should be listed and dont have anything to do with photo content...could be other issues, but for my current content at least that seem to display it all in a proper chronology.
btw, another thing that bugs me and seems to come up about searches of recent activity is regarding confusion when members comments, or editing....wouldnt it be nice if above the members name on these results, is said last edited by, last commented by, or last posted by above names? yes...yes it would :p
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.