Advertisement:

Author Topic: Shared Forum Mod  (Read 311572 times)

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Shared Forum Mod
« on: January 06, 2006, 03:04:39 AM »
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
Code: [Select]
$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid . '&amp;';
To
Code: [Select]
$myurl = $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $Itemid . '&amp;'
 . (isset($_REQUEST['forum']) ? 'forum='.$_REQUEST['forum'].'&amp;' : '');

From
Code: [Select]
$myurl = basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $_REQUEST['Itemid'] . '&amp;' ;
To
Code: [Select]
$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.
« Last Edit: April 29, 2006, 04:16:40 PM by Goosemoose »

Offline chadness

  • Sophist Member
  • *****
  • Posts: 1,025
  • Gender: Male
    • technoadvice.com
Re: Shared Forum Mod
« Reply #1 on: January 06, 2006, 01:40:37 PM »
Wow, that's incredible!  Great work!  Though, my capybara feels slighted.

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Re: Shared Forum Mod
« Reply #2 on: January 06, 2006, 01:45:31 PM »
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 :)

Offline chadness

  • Sophist Member
  • *****
  • Posts: 1,025
  • Gender: Male
    • technoadvice.com
Re: Shared Forum Mod
« Reply #3 on: January 06, 2006, 02:14:28 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #4 on: January 13, 2006, 05:31:40 AM »
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

  • Guest
Re: Shared Forum Mod
« Reply #5 on: January 13, 2006, 10:18:17 AM »
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?

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Re: Shared Forum Mod
« Reply #6 on: January 13, 2006, 01:38:32 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #7 on: January 13, 2006, 02:24:14 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #8 on: January 14, 2006, 02:54:18 AM »
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?

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Re: Shared Forum Mod
« Reply #9 on: January 14, 2006, 04:44:46 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #10 on: January 14, 2006, 05:37:13 PM »
Thanks for all your help!, It's working great now! :)

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Re: Shared Forum Mod
« Reply #11 on: January 14, 2006, 05:47:55 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #12 on: January 16, 2006, 02:54:55 AM »
Thanks That is working too now! :)

SeaOfSin

  • Guest
Re: Shared Forum Mod
« Reply #13 on: January 23, 2006, 05:15:13 PM »
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.

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Re: Shared Forum Mod
« Reply #14 on: January 23, 2006, 07:08:08 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #15 on: January 24, 2006, 02:30:30 AM »
Cool! Thanks for your help

Offline Goosemoose

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,400
  • Gender: Male
    • Goosemoose.com
Re: Shared Forum Mod
« Reply #16 on: January 24, 2006, 03:06:07 PM »
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

  • Guest
Re: Shared Forum Mod
« Reply #17 on: January 25, 2006, 07:45:23 AM »
Thanks, I'll be adding that right away! :)

SeaOfSin

  • Guest
Re: Shared Forum Mod
« Reply #18 on: January 25, 2006, 10:58:47 PM »
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! :)

Offline Slavick

  • Newbie
  • *
  • Posts: 8
Re: Shared Forum Mod
« Reply #19 on: February 11, 2006, 01:22:47 PM »
ok and how do I do this witout joomla? just curious