Updated updated notes: These instructions were written for 0.11b5. Obviously stuff has changed, and where I only included line numbers and not function names or surrounding code in order to place the changes, that might make this process a bit tricky. I might go through the recent code someday and update this guide, but until then, you're on your own!
Updated notes: Well, I got this working. I ain't saying it's pretty, just that it can be done. I've revised and combined my posts into this one. Good luck!
I won't go into the background, but suffice it to say that I needed this to happen, so I made it happen. I think that this is functionality is somewhat sought after, so I thought to share it. It's nothing fancy or complicated, it's actually quite simple. I've been up the past 36 hours getting this to work and putting a site together, so please pardon the breivity of these instructions. I'm simply recounting from memory what I did, I may have forgotten something. Otherwise you just need some basic PHP know-how to get it working. I'm sure lots of people here can help you if you need help with this.
Basic Installation
Step 1: Install CMSMS and SMF. Doesn't matter where. You can use an existing installation perfectly fine.
Adding Content through CMS Admin
Step 2: Go into CMSMS and make a PHP code page. I'm not sure why there isn't simply a page/content type for 'PHP code' with the default installation. Maybe there is, I just haven't seen it. Anyway the way I did it was to simply make a "Custom tag". Call it "forum" and enter the following:
Code: Select all
global $forum_version, $time_start, $maintenance, $mtitle, $mmessage, $mbname, $language, $boardurl, $webmaster_email, $cookiename, $db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_persist, $db_error_send, $boarddir, $sourcedir, $db_last_error, $db_connection, $modSettings, $memcached, $cache_hits, $cache_count, $db_cache, $db_count, $board, $topic, $scripturl, $context, $HTTP_SESSION_VARS, $rand_code, $ban, $log_time, $timeOnlineUpdated, $old_url, $USER_AGENT, $admin_time, $ID_MSG_LAST_VISIT, $unread_messages, $sc, $settings, $user_info, $user_settings, $ID_MEMBER, $txt, $board_info, $options, $db_show_debug, $language_dir, $forum_copyright;
$here = getcwd();
chdir("path/to/SMF/installation");
require "index.php";
chdir($here);
Step 3: Go into CMSMS and make a new page. Call it 'Forums' or whatever you like. For the content, just put in {forum} to call your custom tag code. Go to your CMSMS site and browse to your Forums page. That's it. You should see your SMF forums embeded into the content area of your CMSMS website. If not then you just need to do some troubleshooting.
Now you simply need a few little fixes to get things fully embeded and working seamlessly.
Step 4: Set the "Forums" page as the Default page for your CMSMS website. This is necessary so that all calls which don't contain a "page=..." reference (ie, all the forum calls) will get passed to the forum scripts. The setback here is that the intro page to your site now has to point to the Forums. There are ways to address this. One such way would be to fiddle with your local Apache directives to set a new Index page, such as index.php?page=IntroPage. Then set your original intro page's name to 'IntroPage' - that way anyone who access www.yoursite.com/ can get your original intro page.
Modifying SMF
Step 5: Edit SMF's Settings.php (after you have your forum installed and running) and change $boardurl to point to the base url where you've installed CMSMS (like 'http://www.yoursite.com/'). This is the only alteration to SMF files that is required.
Ok, now you should have a working forum embeded into your CMSMS website that you can actually click around and use. There are now just two additional fixes required.
Modifying CMS
Step 6: Recent changes to the way CMS handles templates and caching has introduced some difficulties in this approach to embeding SMF. Basically what happens though is that the first time the page loads, its contents (whatever forum page you happen to be viewing) gets cached and then whenever you try to view another forum page, you get your first page back again, only displayed in a completely improper way. See this thread for more details on this. Anyway, I didn't have the time or energy to go digging through the CMS-Smarty templating system, so I instituted a nasty quick fix. I disabled caching completely.
This may or may not be a good thing for you to do, I wouldn't advocate you do this for your particular setup unless you were sure of what you were doing (and the additional load on your webserver). It's just a way to get this to work, I leave it to someone else to implement a better fix.
To disable caching for ALL CMS PAGES (make sure you understand what it is you're doing):
Open lib\into content.function.php. Around line 50, replace
Code: Select all
$this->caching = true;
Code: Select all
$this->caching = false;
Step 7: It turns out that CMS tinkers with the superglobals (ie, $_GET) when PHP's magic_quotes_gpc is enabled, which screws up SMF when it receives the variables and thinks that they've been slashed-out (SMF does the opposite of CMSMS and assumes the request variables are all slashed - adding them in if magic_quotes is turned off). The result is that the minute you submit an apostrophe ' into a form field somewhere, you break the database.
You either need to disable magic_quotes which is easily done by adding a line to your .htaccess file, provided your server is configured to allow you to do that (recommended)
Code: Select all
php_flag magic_quotes_gpc off
REPLACE (line ~ 161)
Code: Select all
if(get_magic_quotes_gpc())
Code: Select all
if(get_magic_quotes_gpc() &&! isset($_GET['action']))
Step 8: If your forum handles file uploads (attachments or avatars) then you need to perform this step. If you're accessing files or pictures via the forum script, then you can't have CMSMS outputting all kinds of page junk first, otherwise your files will be corrupted. If we're downloading files, we skip CMSMS.
Open up CMSMS's index.php
Right at the top of the page, ADD the lines
Code: Select all
// Bypass needed for file downloads
if (isset($_GET['action']) && strpos($_SERVER['REQUEST_URI'], 'action=dlattach')) {
require("path/to/SMF/index.php");
exit();
}
Step 9: You're done, that's all the code work. All that is needed now is cosmetic work, mainly tweaking the main SMF template. The most important thing is to CHOP the HTML header stuff. Just delete the , , , , , and tags. The rest is details. Your forum is fully integrated, your site looks good, you don't have to mess around with two seperate templates for your forum and your site, and you get to use all the features, tags, dynamic menus and such on your board.
Step 10: Go out, have a beer.
Working example
[attachment deleted by admin]