|
Latest threads/posts on your site
|
|
08-11-2008, 11:25 PM
(This post was last modified: 08-15-2008 01:30 PM by marines.)
Post: #1
|
|||
|
|||
|
Latest threads/posts on your site
I have written a PHP class which displays last X posts or threads. It will work independent from place which it is ececuted from (it must be placed at least in the same server as MyBB instalation is). Access to "inc/config.php" is neccessary (database login data are got from it). The most convinient is to save class as eg. "MyBBLatest.class.php" and include it in your site. Class will not display anything in case of database errors, so user will not see any unexpected errors. Feel free to use it. I thought GNU GPLv2 license would fit, but don't mind if you have not got bad intentions.
Bellow you can find manual and some usage examples.Manual __constructor(string $mybb, string $url) It executes while class is initialized. First argument contains relative path to main directory of MyBB instalation. For example if your site is placed in root directory and forum is installed in "board" directory just enter "board" here. If page in which you want to display posts/threads is placed in the same directory as board you do not have to enter anything. Just remember about trailing slash! Default: NULL Second argument contains absoute board URL (eg. http://www.siteaddress.com/board/). It is the only argument which is neccessary. Just remember about trailing slash! threads(integer $many, boolean $lastpost, integer $fid) Displays sorted by date threads list. First argument says how many threads has to be displayed. Default: 10 Second argument decides if thread link has to direct to last or first post. Default: false Third argument says from which forum ID threads have to be displayed. If NULL it gets threads from whole board. Default: false posts(integer $many, integer $fid) First argument says how many posts has to be displayed. Default: 10 Second argument says from which forum ID posts have to be displayed. If NULL it gets posts from whole board. Default: false Usage examples I assume that you have saved the class in "MyBBLatest.class.php" in the same folder in which is placed the file in which you want to use it. So let's include the class: PHP Code: require_once('MyBBLatest.class.php'); Now you have to initialize class: PHP Code: $mybb = new MyBBLatest('board', 'http://www.com/board/'); Now you are ready to display latest threads and posts. The most simple way is to make list of 10 latest threads and posts from whole board: PHP Code: echo $mybb->threads();You can add some HTML if you want: PHP Code: <h3>Latest threads</h3>You can display latest 5 threads from forum of ID 2 which direct to last post: PHP Code: <h3>Latest threads from X</h3>In the same way you can do with posts: PHP Code: <h3>Latest posts from forum X</h3>FAQ Q: With which version of MyBB class works? A: I've tested it with 1.4. Q: Why class doesn't allow user to choose look of list easily? A: Because I made this for really PHP beginners. It is very simple to use and that had to be. It is first release and I'm sure I'd include formating in the future.Q: Why don't you keep properly order of arguments in contructor? A: Because I'm sure that almost everybody will use first argument. ![]() Q: Why don't you use MySQLi as database driver? A: Because it is much slower than standard MySQL. I've tested it! It takes about 1.35x more time. And that's it. I am looking forward to your feedback and suggestions. If you need some help with this just ask.Class content PHP Code: <?phpMarines Blog - my techblog Polish MyBB Support |
|||
|
08-12-2008, 02:59 AM
Post: #2
|
|||
|
|||
|
RE: Latest threads/posts on your site
You should probably note that this was written for PHP 5+.
-Doug 1scream Founder Former MyBB Developer & SQA Member My Twitter |
|||
|
08-12-2008, 08:06 AM
Post: #3
|
|||
|
|||
|
RE: Latest threads/posts on your site
PHP4 hasn't got any support now.
Marines Blog - my techblog Polish MyBB Support |
|||
|
08-12-2008, 10:34 AM
Post: #4
|
|||
|
|||
|
RE: Latest threads/posts on your site
Woah, learnt something interesting =]
-favourated- this thread. |
|||
|
08-20-2008, 02:53 AM
Post: #5
|
|||
|
|||
|
RE: Latest threads/posts on your site
excellent sharing
keep it up |
|||
|
08-20-2008, 12:09 PM
Post: #6
|
|||
|
|||
|
RE: Latest threads/posts on your site
hmm... i wonder what functionality can i add to it
Marines Blog - my techblog Polish MyBB Support |
|||
|
08-24-2008, 09:09 PM
Post: #7
|
|||
|
|||
|
RE: Latest threads/posts on your site
I'm getting
Quote:Parse error: syntax error, unexpected '{' in /home/hu/public_html/MyBBLatest.class.php on line 13 Quacktacular Media |
|||
|
08-24-2008, 09:13 PM
Post: #8
|
|||
|
|||
|
RE: Latest threads/posts on your site
show me your code. the most probably you've copied code wrongly.
Marines Blog - my techblog Polish MyBB Support |
|||
|
08-24-2008, 09:21 PM
Post: #9
|
|||
|
|||
|
RE: Latest threads/posts on your site
How do I set the path to my config file properly?
I'm using the class on my WordPress site. MyBBLatest.class.php is located at /home/hu/public_html/MyBBLatest.class.php. The actual MyBB installation is at /home/homeundo/public_html/ Is that all I have to do? Set the path, and then I can call the class using: Code: <?php require_once('/home/hu/public_html/MyBBLatest.class.php'); Quacktacular Media |
|||
|
08-24-2008, 09:24 PM
Post: #10
|
|||
|
|||
|
RE: Latest threads/posts on your site
try without 'board'
![]() Code: $mybb = new MyBBLatest('', 'http://homeundone.com/');Marines Blog - my techblog Polish MyBB Support |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help


Bellow you can find manual and some usage examples.
It is first release and I'm sure I'd include formating in the future.


