System for embedding Phorum in other applications (early preview)
Posted by Maurice Makaay
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 10:04AM |
Registered: 20 years ago Posts: 202 |
I was able to set some dummy variable to get the error to clear but now my question is how do I show the content that was capture from this function call.
include "./phorum/mods/embed_phorum/phorum_block.php";
Do I do echo some variables to display on my page?
Thanks
[opensourceCMS.com]
[ongetc.com]
Chanh Ong
include "./phorum/mods/embed_phorum/phorum_block.php";
Do I do echo some variables to display on my page?
Thanks
[opensourceCMS.com]
[ongetc.com]
Chanh Ong
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 12:35PM |
Admin Registered: 21 years ago Posts: 8,532 |
What phorum_block.php will do is run Phorum and capture all of Phorum's output. The embed_phorum template is setup in such a way that the output contains special sections that are understood by phorum_block.php. These sections are parsed and sent to the connector class' process_page_elements() method to be processed. In the example gitaar.net connector, this is setup as below:
What you'll have to do, is write your own connector class, which will process the $elements array in the way that is needed by your master application's displaying system.
If all that you want to do is echo the Phorum page when you include the phorum_block.php script, then you'll have to write code for this. I doubt however that echoing data is something that you want to do in the process_page_elements() method. For the body of the Phorum output this isn't a problem, but somehow you'll probably want to transfer things like extra <head> data and the page's <title> to the page that is displayed in the end. If you do want to directly print out Phorum pages when including phorum_block.php, you can write a process_page_elements() method in your connector that does just that. Example:
I hope this makes things a bit more clear. The concept that I use here for embedding is very flexable and powerful, but it can be confusing because it's very different from the way that you run Phorum normally. The software is also not finished, so what's missing too is synchronizing of users. Only if users are synchronized from the master system to the Phorum users table, the connectors get_user_id() method makes sense.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
// Setup Phorum's page elements in the master templating system.
function process_page_elements($elements)
{
global $SITE_FRAME;
$SITE_FRAME["SKIN"]->set_title($elements["title"]);
$SITE_FRAME["SKIN"]->add_pre_head_data($elements["style"]);
$SITE_FRAME["SKIN"]->add_post_head_data($elements["head_data"]);
$SITE_FRAME["SKIN"]->add_post_head_data($elements["rss_link"]);
$SITE_FRAME["SKIN"]->add_post_head_data($elements["redirect_meta"]);
$SITE_FRAME["SKIN"]->add_post_head_data($elements["base_href"]);
$SITE_FRAME["SKIN"]->add_body_onload($elements["body_onload"]);
$SITE_FRAME["SKIN"]->add_body_data($elements["body_data"]);
}
$SITE_FRAME is a global variable that I use for my site. In that variable, I have the SKIN, which I use for displaying my pages. As you can see, I call a number of methods on the skin object to pass data to that object. After the included script is finished, nothing is printed on the screen yet. But all data that has to be displayed is put into the right places in my skin object. Finally, my example script will do some calls to site_frame_header()/-body()/-footer(). These will display the page using the right skin and using the data that was produced by Phorum.
What you'll have to do, is write your own connector class, which will process the $elements array in the way that is needed by your master application's displaying system.
If all that you want to do is echo the Phorum page when you include the phorum_block.php script, then you'll have to write code for this. I doubt however that echoing data is something that you want to do in the process_page_elements() method. For the body of the Phorum output this isn't a problem, but somehow you'll probably want to transfer things like extra <head> data and the page's <title> to the page that is displayed in the end. If you do want to directly print out Phorum pages when including phorum_block.php, you can write a process_page_elements() method in your connector that does just that. Example:
function process_page_elements($elements)
{
print $elements["redirect_meta"];
print $elements["style"];
print $elements["rss_link"];
print $elements["redirect_meta"];
print $elements["body_data"];
}
But IMO, the moment that you start doing this, you're no longer embedding Phorum in a webpage. Or maybe you're embedding Phorum, but things like the <style> declaration will fall outside your master application's <head> section this way (since you're know printing all that information inside the <body> of the page that you are embedding Phorum in.
I hope this makes things a bit more clear. The concept that I use here for embedding is very flexable and powerful, but it can be confusing because it's very different from the way that you run Phorum normally. The software is also not finished, so what's missing too is synchronizing of users. Only if users are synchronized from the master system to the Phorum users table, the connectors get_user_id() method makes sense.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 01:58PM |
Registered: 20 years ago Posts: 202 |
I am starting to understand your mods and I am able to get my little connector and a dummy page to show phorum post.
I would love to see what you come up with on your Mambo experiement with this mods.
I will play with this a little more to understand.
Great mods!
Thanks
[opensourceCMS.com]
[ongetc.com]
Chanh Ong
I would love to see what you come up with on your Mambo experiement with this mods.
I will play with this a little more to understand.
Great mods!
Thanks
[opensourceCMS.com]
[ongetc.com]
Chanh Ong
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 04:20PM |
Admin Registered: 21 years ago Posts: 8,532 |
I just finished some more things in the mod.
The connector now has to implement a method get_slave_fields(), that has to return an array of fields that Phorum may edit through the user's control center. Both the front-end (though the templates) and the back-end (by filtering user fields before saving them) are aware of this array. So now you can configure what user fields will be synchronized from the master application and what fields the user can edit through the control center.
File downloading through file.php now works. Things went wrong, because file.php checks if the referring URL is at or below the Phorum's http_path setting. If off-site links are not allowed, now only the hostname in the http_path and the hostname in the referrer are compared. That is good enough I think.
Output of both the file and RSS scripts is now handled correctly by phorum_block.php. The output of those scripts should not be processed, but should be sent directly to the browser. Before handling these pages, the phorum_block.php script calls ob_clean() to get rid of data that the master application already may have sent (for that to work, the master should have called ob_start() before starting its output of course).
Furthermore some small bugs and improvements are made. Check the first post for an updated package. I renamed the template-set directory in the package to "embed_phorum-template". And because I think it's clearer, I renamed "phorum_block.php" to "run_phorum.php".
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
The connector now has to implement a method get_slave_fields(), that has to return an array of fields that Phorum may edit through the user's control center. Both the front-end (though the templates) and the back-end (by filtering user fields before saving them) are aware of this array. So now you can configure what user fields will be synchronized from the master application and what fields the user can edit through the control center.
File downloading through file.php now works. Things went wrong, because file.php checks if the referring URL is at or below the Phorum's http_path setting. If off-site links are not allowed, now only the hostname in the http_path and the hostname in the referrer are compared. That is good enough I think.
Output of both the file and RSS scripts is now handled correctly by phorum_block.php. The output of those scripts should not be processed, but should be sent directly to the browser. Before handling these pages, the phorum_block.php script calls ob_clean() to get rid of data that the master application already may have sent (for that to work, the master should have called ob_start() before starting its output of course).
Furthermore some small bugs and improvements are made. Check the first post for an updated package. I renamed the template-set directory in the package to "embed_phorum-template". And because I think it's clearer, I renamed "phorum_block.php" to "run_phorum.php".
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 06:06PM |
Admin Registered: 21 years ago Posts: 8,532 |
Some more changes, which make the embedding work in full for my site. Check out the first posting in this thread for the download link of the package.
Changelog:
----------
0.0.3 2006-02-04
Renamed the connector method get_userid() to get_user_id() (so the
name matches the user_id field).
Added a user synchronization script "syncuser.php". This script contains
an easy function for synchronizing users with the Phorum database.
Extended connectors/gitaar.net/connector.php (the example connector,
which I use for embedding Phorum in my own website) with on-the-fly user
synchronization using the syncuser.php script. The user synchronization
could also be done outside the connector, but this is the easiest way
to do it. When the connector is run, you're already in the Phorum
environment where you can use the Phorum database directly.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Changelog:
----------
0.0.3 2006-02-04
Renamed the connector method get_userid() to get_user_id() (so the
name matches the user_id field).
Added a user synchronization script "syncuser.php". This script contains
an easy function for synchronizing users with the Phorum database.
Extended connectors/gitaar.net/connector.php (the example connector,
which I use for embedding Phorum in my own website) with on-the-fly user
synchronization using the syncuser.php script. The user synchronization
could also be done outside the connector, but this is the easiest way
to do it. When the connector is run, you're already in the Phorum
environment where you can use the Phorum database directly.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 06:37PM |
Registered: 20 years ago Posts: 36 |
Quote
mmakaay
That's a strange error you get here. I have no clue why you would get that error message. Once chdir() has been done to the phorum directory, template files should be found.
Wait... you copied the template to "template_forum"? It should be "embed_phorum", looking at the error message you get. In my connector class, I set the template fixed to "embed_phorum". If you are working based on that class, you'll have to match the template name used in there. If you do not set the template from your connector, you should be able to select it as the template to use from your admin interface. I find it most convenient to set the template directly from the connector though.
Hemm...
Here is what I did, I install phorum on phorum dir. I copy the template-dist to phorum/templates folder and rename the template-dist folder into embed_phorum. Is that how it's suppose to be? I did that already from the beginning, but that's the error that I receive.
The directory for the embed phorum is like this "phorum/templates/embed_phorum/"
Any thoght on this?
Thanks Maurice :)
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 09:27PM |
Admin Registered: 21 years ago Posts: 8,532 |
@wendy: That folder is correct, so Phorum should be able to find the templates. If you have the embed_phorum module disabled in the control panel, can you then set that template for a forum and see if the template is applied when you visit that forum?
@all interested in (Mambo) integration:
I hacked up a quick first component (My First Mambo Component ;-) to check if I could embed Phorum with the code that I have created so far. A first, very rought implementation is now running at [mambo.gitaar.net]
What will be changed to the current connector code, based on my first experiences with Mambo, is that the PhorumConnector object will be created very early on in the run_phorum.php script. That way, I can also let the connector determine the behaviour for the rewriting and parsing of URL's. I quite soon found out that the rewrite options that are in run_phorum.php are not sufficient for Mambo (because Mambo puts a lot of info in the URL too).
So far so good. I hope to have a first release on a mambo connector by tomorrow.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
@all interested in (Mambo) integration:
I hacked up a quick first component (My First Mambo Component ;-) to check if I could embed Phorum with the code that I have created so far. A first, very rought implementation is now running at [mambo.gitaar.net]
What will be changed to the current connector code, based on my first experiences with Mambo, is that the PhorumConnector object will be created very early on in the run_phorum.php script. That way, I can also let the connector determine the behaviour for the rewriting and parsing of URL's. I quite soon found out that the rewrite options that are in run_phorum.php are not sufficient for Mambo (because Mambo puts a lot of info in the URL too).
So far so good. I hope to have a first release on a mambo connector by tomorrow.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 09:42PM |
Registered: 20 years ago Posts: 202 |
Well, I installed the latest mods, apply the template and copy your connector to make my connection where it just assign some dummy variables and print the element array from the connector.
I create a dummy page like below but I got the error below. What am I missing?
<?php
echo "Welcome to main page of embeded phorum<br />";
require_once("../phorum/mods/embed_phorum/PhorumConnectorBase.php");
require_once("../phorum/mods/embed_phorum/connectors/gitaar.net/Myconnector.php");
include "../phorum/mods/embed_phorum/run_phorum.php";
echo "Footer of my main page";
?>
Welcome to main page of embeded phorum
Fatal error: Maximum execution time of 30 seconds exceeded in f:\wamp\www\phorum\include\templates.php on line 339
[opensourceCMS.com]
[ongetc.com]
Chanh Ong
I create a dummy page like below but I got the error below. What am I missing?
<?php
echo "Welcome to main page of embeded phorum<br />";
require_once("../phorum/mods/embed_phorum/PhorumConnectorBase.php");
require_once("../phorum/mods/embed_phorum/connectors/gitaar.net/Myconnector.php");
include "../phorum/mods/embed_phorum/run_phorum.php";
echo "Footer of my main page";
?>
Welcome to main page of embeded phorum
Fatal error: Maximum execution time of 30 seconds exceeded in f:\wamp\www\phorum\include\templates.php on line 339
[opensourceCMS.com]
[ongetc.com]
Chanh Ong
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 09:59PM |
Admin Registered: 21 years ago Posts: 8,532 |
That execution time problem has nothing to do with the embedding software IMO. If you could track (down by putting some print statements in the templates.php or so) what your templates.php script is doing when you get that error, it would be most helpful. I have never been able to reproduce that error, but I have seen more reports about it. My best guess is that the software is getting into a loop somewhere.
Could you also give me information about your system? Like OS, Server type + version, PHP version.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Could you also give me information about your system? Like OS, Server type + version, PHP version.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
Re: System for embedding Phorum in other applications (early preview) February 05, 2006 10:10PM |
Registered: 20 years ago Posts: 36 |
Thanks for the fast reply Maurice.
I disabled the mod, and this is what I got:
No embedding connector is available in the Phorum environment. This probably means that the embed_phorum module was not activated in the admin interface.
If I enabled it again, I got this again:
fopen(./templates/embed_phorum/settings.tpl): failed to open stream: No such file or directory
I think the system able to find the files when I disable the mod, don't you think? Any reply will be great.
Thanks Maurice.
I disabled the mod, and this is what I got:
No embedding connector is available in the Phorum environment. This probably means that the embed_phorum module was not activated in the admin interface.
If I enabled it again, I got this again:
fopen(./templates/embed_phorum/settings.tpl): failed to open stream: No such file or directory
I think the system able to find the files when I disable the mod, don't you think? Any reply will be great.
Thanks Maurice.
Your IP address, domain or ISP has been blocked. Please contact the forum administrators.
Sorry, only registered users may post in this forum.


