How to use BBCode into an external website ?
Posted by .IrØniK
|
How to use BBCode into an external website ? December 15, 2009 11:44AM |
Registered: 16 years ago Posts: 9 |
Hi. I need to use BBCode on my website (I'm a php coder) and I don't know what file(s) or function(s) I've got to include in my code. My phorum files are in the '/forum' directory and the page where I want the BBCode to apply is 'index.php' (in the root directory).
Thanks in advance for you help.
P.S : Sorry if there're some mistakes, I'm not fluent in English ^^.
Edited 1 time(s). Last edit at 12/15/2009 11:45AM by .IrØniK.
Thanks in advance for you help.
P.S : Sorry if there're some mistakes, I'm not fluent in English ^^.
Edited 1 time(s). Last edit at 12/15/2009 11:45AM by .IrØniK.
|
Re: How to use BBCode into an external website ? December 15, 2009 02:35PM |
Admin Registered: 23 years ago Posts: 9,240 |
|
Re: How to use BBCode into an external website ? December 16, 2009 03:37AM |
Registered: 16 years ago Posts: 9 |
I've already done that. I've tried this in my page index.php :
[code="php"]
require_once('forum/mods/bbcode/bbcode.php');
[/code]
and after typing that :
[code="php"]
echo phorum_mod_bbcode_format('test');
[/code]
...php displays the following message :
Fatal error: Call to undefined function bbcode_api_initparser() in /home/a3574827/public_html/includes/bbcode/bbcode.php on line 41
The function bbcode_api_initparser() is definitely undefined...
What is the problem ?
Edited 1 time(s). Last edit at 12/16/2009 03:39AM by .IrØniK.
[code="php"]
require_once('forum/mods/bbcode/bbcode.php');
[/code]
and after typing that :
[code="php"]
echo phorum_mod_bbcode_format('test');
[/code]
...php displays the following message :
Fatal error: Call to undefined function bbcode_api_initparser() in /home/a3574827/public_html/includes/bbcode/bbcode.php on line 41
The function bbcode_api_initparser() is definitely undefined...
What is the problem ?
Edited 1 time(s). Last edit at 12/16/2009 03:39AM by .IrØniK.
|
Re: How to use BBCode into an external website ? December 16, 2009 03:52AM |
Admin Registered: 23 years ago Posts: 9,240 |
you didn't look at the code at all.
The module does some includes in the beginning:
[code="php"]
require_once('./mods/bbcode/api.php');
require_once('./mods/bbcode/builtin_tags.php');
require_once('./mods/bbcode/defaults.php');
[/code]
Therefore you need to "chdir" to the phorum directory before including the bbcode.php file (search the forums, this was explained a lot)-
Also it expects as input an array of messages with body and subject which are formatted accordingly.
Thomas Seifert
The module does some includes in the beginning:
[code="php"]
require_once('./mods/bbcode/api.php');
require_once('./mods/bbcode/builtin_tags.php');
require_once('./mods/bbcode/defaults.php');
[/code]
Therefore you need to "chdir" to the phorum directory before including the bbcode.php file (search the forums, this was explained a lot)-
Also it expects as input an array of messages with body and subject which are formatted accordingly.
Thomas Seifert
|
Re: How to use BBCode into an external website ? December 16, 2009 05:25AM |
Registered: 16 years ago Posts: 9 |
Quote
Thomas Seifert
you didn't look at the code at all.
I did...
Well, I put this at the beginning of my page :
[code="php"]
chdir('forum');
require_once('./common.php');
require_once('./mods/bbcode/api.php');
require_once('./mods/bbcode/builtin_tags.php');
require_once('./mods/bbcode/defaults.php');
require_once('./mods/bbcode/bbcode.php');
echo phorum_mod_bbcode_format('test');
[/code]
and I got :
Warning: Invalid argument supplied for foreach() in /home/a3574827/public_html/forum/mods/bbcode/bbcode.php on line 45
Here's the 45th line of bbcode.php :
[code="php"]
foreach ($data as $message_id => $message)
[/code]
I suppose either $message_id or $message (or both) are empty or something like that.
Thanks for your help.
|
Re: How to use BBCode into an external website ? December 16, 2009 05:44AM |
Admin Registered: 23 years ago Posts: 9,240 |
quoting myself again ...
your input won't work but needs to be an array containing your data.
something like (not tested):
[code="php"]
print_r(phorum_mod_bbcode_format(array(array('body'=>'test','subject'=>''));
[/code]
Thomas Seifert
Quote
Also it expects as input an array of messages with body and subject which are formatted accordingly.
your input won't work but needs to be an array containing your data.
something like (not tested):
[code="php"]
print_r(phorum_mod_bbcode_format(array(array('body'=>'test','subject'=>''));
[/code]
Thomas Seifert
|
Re: How to use BBCode into an external website ? December 16, 2009 05:51AM |
Moderator Registered: 19 years ago Posts: 1,301 |
Quote
Thomas Seifert
Also it expects as input an array of messages with body and subject which are formatted accordingly.
I you look further in the bbcode.php file you will see:
[code="php" number="56"]
$body = $message["body"];
[/code]
So, for your purposes:
[code="php"]
echo phorum_mod_bbcode_format('test');
[/code]
should be:
[code="php"]
$test_text = array(1 => array("body" => "test"));
$formatted_text = phorum_mod_bbcode_format($test_text);
echo $formatted_text[1]["body"];
[/code]
Also, once you change directory, you do not need to call the other required bbcode module files as the module does that itself. You will need to return to your original working directory after you have run the bbcode formatting. The easiest way to do that is:
$curdir = getcwd();
chdir('forum');
. . .
chdir($curdir);
Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
|
Re: How to use BBCode into an external website ? December 16, 2009 08:30AM |
Registered: 16 years ago Posts: 9 |
|
Re: How to use BBCode into an external website ? December 16, 2009 10:17AM |
Admin Registered: 21 years ago Posts: 8,532 |
|
Re: How to use BBCode into an external website ? December 16, 2009 12:37PM |
Registered: 16 years ago Posts: 9 |
Sorry, only registered users may post in this forum.
