News:

Wondering if this will always be free?  See why free is better.

Main Menu

Shared Forum Mod

Started by Goosemoose, January 06, 2006, 03:04:39 AM

Previous topic - Next topic

Goosemoose

Orstio and I came up with a way to run multiple forums from 1 database, 1 directory, 1 installation. I'm running 7 forums and I only need to upgrade once, install mods once, and my users are shared :)

First the examples. Note the number of Categories that show in each, and that some are shared. some aren't.

http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rat
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,cat
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,dog
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,hedgehog
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rabbit
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,ferret
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,bird

Ok, you can do it without the Mambo/Joomla bridge but it's no where near as good. We used the power of the bridge to rewrite all the links. Basically what you do is create a new table smf_forums that houses two fields, forumName and catList. Here is an example of what it could look like with 3 forums that share some categories, and have some unique. This all works off of ONE smf directory!

forumName catList
Rat 1,2,3,4
Cat 1,5,6,7
Dog 1,4,8,9

Ok so here are the steps.

1. Run this in phpMyAdmin
Code:


CREATE TABLE IF NOT EXISTS `smf_forums` (
  `forumName` text NOT NULL,
  `catList` varchar(128) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


2. Go in and add your fields like the example above forumName is the name you'll be passing in, catList are the category id's you want to display for that forum. If your prefix isn't smf_ , make sure to change it.

3. Edit Load.php

In Load.php

Find:
Code:

$user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.memberGroups) OR FIND_IN_SET(', $user_info['groups']) . ', b.memberGroups))';   


Add After:
Code:

// Added for the multiple forum mod
    if(!empty($_REQUEST['forum']) && !isset($_REQUEST['action']) && !isset($_REQUEST['board']) &&!isset($_REQUEST['topic'])){
      $forumList = db_query("SELECT catList FROM {$db_prefix}forums WHERE forumName = '$_REQUEST[forum]'", __FILE__, __LINE__);
      $row_forumList = mysql_fetch_assoc($forumList);
      $user_info['query_see_board'] .= ' AND FIND_IN_SET(c.ID_CAT, "' . $row_forumList['catList'] . '")';     
   }


4. In BoardIndex.php (in Sources dir)

find:
Code:
         AND b.childLevel <= 1" : ''), __FILE__, __LINE__);

replace with:
         AND b.childLevel <= 1" : '') . " ORDER BY c.catOrder, b.boardOrder ASC" , __FILE__, __LINE__);

5. In smf.php in the component directory for the bridge, this $myurl= line is in 4 places but slightly different each time. You can copy the same line to all 3 places without a problem.

For version 1.1x of the bridge do the following:
From
$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid . '&amp;';

To
$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid . '&amp;'
. (isset($_REQUEST['forum']) ? 'forum='.$_REQUEST['forum'].'&amp;' : '');


From
$myurl = basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;' ;

To
$myurl = basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;'
.  (isset($_REQUEST['forum']) ? 'forum='.$_REQUEST['forum'].'&amp;' : '');


-------------
In older versions of the bridge do the following to smf.php
Find:
Code:

$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid. '&amp;';

and find:

$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid . '&amp;';


Replace both with:
Code:

$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid. '&amp;'.  (isset($_REQUEST['forum']) ? 'forum='.$_REQUEST['forum'].'&amp;' : '');

Find:

   $myurl = sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;' );

Replace with:

    $myurl = sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;' .  (isset($_REQUEST['forum']) ? 'forum='.$_REQUEST['forum'].'&amp;' : ''));
----------------------------------------------

6. The following fix thanks to Kingconnor

Open "yourforumdir/Sources/BoardIndex.php" and find the following code

$result_boards = db_query (around line 71)

Add above that the following code (might look familiar)

   // Added for the multiple forum mod
    if(!empty($_REQUEST['forum']) && !isset($_REQUEST['board']) &&!isset($_REQUEST['topic'])){
      $forumList = db_query("SELECT catList FROM {$db_prefix}forums WHERE forumName = '$_REQUEST[forum]'", __FILE__, __LINE__);
      $row_forumList = mysql_fetch_assoc($forumList);
     $user_info['query_see_board'] .= ' AND FIND_IN_SET(c.ID_CAT, "' . $row_forumList['catList'] . '")';
   }

7. Create a link to your new forums! Here is an example using SEF:
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rat
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,cat
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,dog

Without SEF would be like this (note I use SEF so it will switch after the first page)
http://www.goosemoose.com/index.php?option=com_smf&Itemid=118&forum=rat

Note that if you leave the forum part off you see all the boards.

chadness

Wow, that's incredible!  Great work!  Though, my capybara feels slighted.

Goosemoose

Glad you like it. Do you really have a capybara? You should post some pictures on the forum. Those are huge! I am planning on adding quite a few more forums. I was able to add 5 additional forums in a matter of minutes which makes it so I can add more animal sections now :)

chadness

I don't really, I just wanted to give you a hard time. :)  I just have your standard pets, an okapi and a puffin.  Or maybe they're a dog and a cat.

SeaOfSin

Great mod, this is exactly what I was looking for but two things, firstly when I add the following line I get this error

Parse error: parse error, unexpected ';' in /home/revolut/public_html/components/com_smf/smf.php on line 494

Find:

   $myurl = sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;' );

Replace with:

    $myurl = sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;' .  (isset($_REQUEST['forum']) ? 'forum='.$_REQUEST['forum'].'&amp;' : '');

If I keep the line as it is it works fine. Is this going to be a problem?

Secondly when I access the separate forums the board order is messed up. Is there any way to resolve that?

SeaOfSin

I think I see what it is doing, but I don't know what to do about it. It is sorting by ID_BOARD instead of boardOrder. Is there anyway to change this?

Goosemoose

I had that problem too, but I thought it was just me. You have to add an order by desc command into load.php. I'll look it up and post it in a few minutes.

I'll have to look into the other error, I had no problem with it. You do want all the updates in there otherwise certain things won't work right.

SeaOfSin

Well it does seem to be working without that part fine. So unless I run into problems I'm not too worried.  But I do have all the latest versions of everything. :)

I will await they code for the sorting of the boards.  :)

Thanks for your help.

SeaOfSin

I upgraded the bridge to 1.1.2 and still have the same problem, but it works fine if I don't change it the last part.

Any luck on the board sort?

Goosemoose

Yup!

Open up BoardIndex.php in your sources directory:

find:
         AND b.childLevel <= 1" : ''), __FILE__, __LINE__);

replace with:
         AND b.childLevel <= 1" : '') . " ORDER BY c.catOrder, b.boardOrder ASC" , __FILE__, __LINE__);

SeaOfSin

Thanks for all your help!, It's working great now! :)

Goosemoose

Fixed the other problem too, and updated the first post. The line you were having a problem with should have ended )); rather than ); Make sure to update it, it is important!

SeaOfSin

Thanks That is working too now! :)

SeaOfSin

Another question....How did you get the SMF login to go to the correct forum?  Everytime someone logs in on SMF and not the Joomla it shows all the boards.

Goosemoose

I have a redirect in index.php that automatically redirects when used if the access is not from a mobile phone. I'll get the code for you in a bit as I'm on a different machine right now.

SeaOfSin

Cool! Thanks for your help

Goosemoose

Sorry it took me so long, I got caught up at work last night.

Open up index.php

Find:
if (!defined('WIRELESS'))
   define('WIRELESS', isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']));

Add after:
if (!WIRELESS && empty($_REQUEST['option'])){   
   header('Location: http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rat');
}

Obviously change the link to the joomla page you want to redirect them to.

SeaOfSin

Thanks, I'll be adding that right away! :)

SeaOfSin

Well, I managed to get it working. I had a bit of a problem with uploading avatars for some reason but managed to get that working to. but anyway thanks for your help! :)

Slavick

ok and how do I do this witout joomla? just curious

Advertisement: