Firefox PHP

No "official" integration tutorial anywhere??

Posted by tobefound 
No "official" integration tutorial anywhere??
January 28, 2010 06:41AM
Hi guys,

Phorum seems like a great and clean piece of forum app!

But I must say, where are the docs for integration? Sure, there is an API and a dev doc but they target experienced Phorum hackers if you ask me (or focus a lot on MODs). I'm a quite seasoned programmer and of course, I can dig through the forums to find things out, now I'm simply curious as to why there are no official integration documentation?

For example, phorum has a beatiful API listing (even for the database layer!) but I can't find ANY official documentation on how to access this API?

Here's my php webpage, how do I start using an API function?

Language: PHP
include(';my_webpage_header.php';);   //how can I access this? $phorum_api_user_authenticate(...);   include(';my_webpage_login.php';); include(';my_webpage_footer.php';);

Also, somebody mentioned there is a Phorum portable code package/folder. And so I found it in the phorum path, simply called 'portable'. But how do I use it or more importantly, its presence seems to be officially advertised nowhere, why...??

Sorry for being grumpy, but these are things that should be easily available... Actually to such an extent that I'm beginning to think I'm stupid or really overlooking something very obvious?

Any help is greatly appreciated,

/T
Re: No "official" integration tutorial anywhere??
January 28, 2010 09:56AM
There is no "one-way-fits-all" integration and there are no official docs for that but we happily accept your contribution on that.

A simple way to call the api functions is this part ...

Language: PHP
define(';phorum_page';, ';mypage';); // to avoid some warnings ...   $cwd = getcwd(); chdir(';./forum';); // or whatever your phorum dir is include_once("./common.php");   /* call whatever api function you need */   chdir($cwd);

The portable code is not a drop-in solution and has its docs inline.


Thomas Seifert
Re: No "official" integration tutorial anywhere??
January 28, 2010 02:40PM
Wow, thanks!

That piece of code must be generic enough to be put at the top of the API page if you ask me!

Follow-upers:

1) I assume common.php loads the whole enchilada, if I want to load functions specific to my task, is there a way? Because I don't think I can only/simply load the files listed as being the container files for the API functions?

2) How name clashing safe if the code of Phorum? I mean, when including common.php, will Phorum functions collide with my cms or other framework functions? I tried phpBB a while ago and that was a big no-no as its "redirect()" function clashed bigtime.

3) I'm not really sure what you mean by "to avoid warnings"?

4) Interesting: using the API functions, is it possible to produce the output to that of the standard domain.com/phorum output? In that case, that's seems to be the closest match to a generic integration tutorial.

/T
Re: No "official" integration tutorial anywhere??
January 28, 2010 02:47PM
Function names should be name clashing safe and most data is saved in the $PHORUM array.

Avoiding some php warnings is done with that define as phorum assumes a phorum_page constant everywhere.

Not everything is in an api yet. So you will have to load and do more stuff than just using api functions to get some output.


Thomas Seifert
Re: No "official" integration tutorial anywhere??
January 28, 2010 06:30PM
Thx for the reply. How about numero uno?

/T
Re: No "official" integration tutorial anywhere??
January 29, 2010 10:57AM
common.php is more than only a loader script. As such, you cannot really omit loading that file when you need Phorum functionality. In 5.3 we are in the process of transferring more of the functionality into API's, but it's work in progress. Maybe, a future release will allow you to only load a very small core (there's already some autoloading functionality available in 5.3-dev to handle loading automatically-when-needed), but for now you'll have to load common.php (or extract the required parts yourself).


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: No "official" integration tutorial anywhere??
January 31, 2010 05:10PM
And by including common.php I have access to the user properties and the entire API?

It would for instance allow me to (only if the user is logged in this case) list the 5 latest posts in a particular forum?

/T
Re: No "official" integration tutorial anywhere??
January 31, 2010 05:27PM
Your questions are rather unfocused. I'll try to provide some answers anyway.

You have access to user properties.
"The user" is the authenticated user? You have access to that too.
You have access to the part of the API that is loaded. Other parts of the API can be loaded when needed.
If you program the code for it, it would allow you to create the 5 latest post list that you are talking about. There is no function provide_latest_5_messages_when_user_is_logged_in() or so, but it can surely be built.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: No "official" integration tutorial anywhere??
February 01, 2010 08:59AM
Ok, thx.

However, Thomas said:

include_once("./common.php");
/* call whatever api function you need */

I'm confused... Or should I first include common.php and then include the file(s) listed under the categorized function names in the API doc?

/T
Re: No "official" integration tutorial anywhere??
February 01, 2010 10:26AM
In a php program the "include_once("./common.php");" will load the phorum php programs that handle all of the api functions as well as the phorum variables, etc and make them available to the program that has that call in it. It does not universally make them available to other programs running on your server.
Sorry, only registered users may post in this forum.

Click here to login