News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Shared Forum Mod

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

Previous topic - Next topic

Goosemoose

No problem farren. Post your site when you're down so other people can check out the mod in use :)

Neol

#101
Quote from: Goosemoose on July 11, 2006, 09:23:04 PM

Quote from: tracilynnb on June 11, 2006, 03:58:50 PM
Another question, if you don't mind... is there a way to filter recent unread posts across forums...  For example on your site if you were on the "rats" forums, when you select Show unread posts since last visit, you would only see the unread posts from the "rats" forums and not all the others?

It shouldn't be too hard, I'm just swamped right now. You basically need to add another join to the query that makes sure the posts are part of the forums listed in the current forum. Hopefully someone else can jump in and help you out.

Quote from: 2kreative on July 10, 2006, 01:00:39 PM
Thx for the feedback goose..that help wiht my decision...

btw
Do all of the forums have to share the same header?

By default they do, but it would be easy to set up several and change them based on the current forum. I do this myself as my rat forum as a different logo that loads, and the others don't.

Goosemoose, would you please tell us how did you implement the above 2 features (unread posts since last visit just for the forum where the user is logged in, and different headers for different forums) in your site?

For unread posts, I looked at Recent.php in the Sources directory for SMF 1.1 RC2 and it seems that the way it is normally done in the original code (for all of the forum) is through the function UnreadTopics (starts around line 428). It does mention using the parameter 'boards'; I think it can be used like this:

http://www.simplemachines.org/community/index.php?action=unread;boards=1,2,5;start=0

Using this kind of URL, you can see unread posts/topics only for specific boards (1, 2 and 5 in this example) which is just what tracilynnb and I need to implement.

In the example presented by Goosemoose in the first post of this topic, the "Dog" forum consists of boards 1, 4, 8, and 9. So the above link would be (I think):

http://www.goosemoose.com/index.php?option=com_smf&Itemid=118&forum=dog&action=unread;boards=1,4,8,9;start=0

The question is: How can we make SMF generate the link on the fly, so that the URL contains board numbers for the specific forum the user is logged in?

Or, the function UnreadTopics could be patched to also use the 'forum' parameter, in order to get and display unread posts only for that forum, for example through JOIN commands; this way, it wouldn't be necessary to use the 'boards' URL parameter.

Any help?

Goosemoose

olti,
The different headers is pretty easy. I just have an if statement that checks what forum is being visited then display the code I want. For example, the rat forum has a logo in the header that the other forums don't have. I used the following code which makes sure that we are looking at the rat forum:

// If we are on the rat forum show it's logo
echo '
</td>';
if(isset($_REQUEST['forum']) && $_REQUEST['forum'] == 'rat'){
echo '
<td color="#000000" bgcolor="#F6F6F6" height="88"><img src="http://www.goosemoose.com/rfc/Themes/default/images/ratsrulelogo.jpg" width="306.18" height="87.48"/></td>
';
}


I will play around with the unread topics a bit. I thought I had figued it out, but it's not playing along. Remember you actually list categories so you want something similar to
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rat/action,unread/c,1,31

Neol

Goosemoose, thanks for the reply! In which file did you put the code for the different header, and where in the file?

As for the unread posts/topics issue, I agree that it has to do with categories rather than boards. I stand corrected. :) I'm really looking forward to a solution.


Neol

#104
About unread topics: I think a way might be to fetch which categories belong to a forum (using the smf_forums table), then which boards belong to each category, then to extract unread posts for each board, and finally display them all (unread posts for the boards in categories of the forum).

Or, existing code could be reused to combine unread topics for the first category of the forum + unread posts for the second category + 3rd + ... = unread posts for the forum, using foreach (perhaps just like in the code for boards).

The code for the function UnreadTopics in Recent.php could be a good starting point. What do you think?

If I may ask, in what way is the code you developed not playing along?

Goosemoose

The code for the headers is in your themes index.template.php. Exactly where you put the code depends on what changes you want to make. Search for the word header and you will find the right area. Then it's just a matter of playing around until you get the right spot. Make sure to back up the original file first ;)

The unread posts is a matter of me working on it at 3am. If I have some time I'll play with it later today.

tracilynnb

Looking forward to a solution for this as well - thanks ;)
SMF 1.1.1
Joomla Bridge 1.6
Joomla 1.0.12

Neol

#107
Goosemoose, I have some questions about your code in page 1:

1) Wouldn't it be more appropriate if $forumList and $row_forumList were named $catList and $row_catList, respectively? I ask this question because the value of $forumList is set to the contents of the catList field in the smf_forums table.

2) Shouldn't $forumList be freed with the following (both in Load.php and BoardIndex.php, just before the closing } of the if construct)?
mysql_free_result($forumList);

3) Before checking if $_REQUEST['forum'] is empty, shouldn't we check if it is set first? Or does empty() do that too?
if (isset($_REQUEST['forum']) && !empty($_REQUEST['forum']) && ...

Neol

#108
Quote from: Goosemoose on August 20, 2006, 04:52:13 AM
Remember you actually list categories so you want something similar to
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rat/action,unread/c,1,31

To display unread topics for the currently logged in forum only, I used the fix thanks to Kingconnor and used implode(). I also added the mysql_free_result() statement that I suggested in the previous post.

ADDED INFO: The code below also works for "Show new replies to your posts", which are displayed only for the currently logged-in forum.

I don't know if (dare I say) my code is correct, safe or secure, so use it at your own risk. I have only tested it locally, and I wrote it just a few minutes ago, so I haven't done any extensive tests. Corrections, comments etc. are very welcome, desired in fact!

Basically, the function UnreadTopics() in Recent.php checks - among other things - if categories are specified in the URL; if yes, it displays unread topics for those categories only (I got this hint from Goosemoose; see the quoted example). The check starts in Recent.php at the following line:
elseif (!empty($_REQUEST['c']))

So, what we need to do is set the value of the $_REQUEST['c'] variable to the list of categories for the currently logged in forum. That's what the code below does.

Open Recent.php in the Sources directory and find the line:
// Are we specifying any specific board?

Add just above that the following code:
// 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'] . '")';
$_REQUEST['c'] = implode(',', $row_forumList);
mysql_free_result($forumList);
}


Goosemoose, can you check if this piece of code is correct? Also, I don't know why the line below doesn't work (I commented it out in the code above), or even if it's needed or not:
$user_info['query_see_board'] .= ' AND FIND_IN_SET(c.ID_CAT, "' . $row_forumList['catList'] . '")';

If I leave the line above intact (as in the original code in page 1), an error message appears when I click on the unread posts link:



I have to comment out the line in order for Show unread posts since last visit to work.

Neol

#109
It seems that the live (not the test) forum is having the same problem as tracilynnb since yesterday.

Reply #59 - http://www.simplemachines.org/community/index.php?topic=64492.msg579037#msg579037

Possible cause: a new theme was installed yesterday.

On the other hand, the test forum in localhost is loaded with the default theme and runs fine, but some part of the code didn't work when I reused it to create the unread topics filter. See my last post above. Specifically, only when I commented out the line below in Recent.php did the test forum work fine:

$user_info['query_see_board'] .= ' AND FIND_IN_SET(c.ID_CAT, "' . $row_forumList['catList'] . '")';

Can someone explain why is that line necessary? What is supposed to happen if I leave it out? Specifically, which table is c supposed to represent and why can't the rest of the code seem to find it?

My test forum in localhost is a "rat, cat, dog" forum, created from scratch exactly for the purpose of trying out the mod.

tracilynnb

Quote from: olti on August 22, 2006, 03:26:52 AM
Quote from: Goosemoose on August 20, 2006, 04:52:13 AM
Remember you actually list categories so you want something similar to
http://www.goosemoose.com/component/option,com_smf/Itemid,118/forum,rat/action,unread/c,1,31

To display unread topics for the currently logged in forum only, I used the fix thanks to Kingconnor and used implode(). I also added the mysql_free_result() statement that I suggested in the previous post.

I don't know if (dare I say) my code is correct, safe or secure, so use it at your own risk. I have only tested it locally, and I wrote it just a few minutes ago, so I haven't done any extensive tests. Corrections, comments etc. are very welcome, desired in fact!

Basically, the function UnreadTopics() in Recent.php checks - among other things - if categories are specified in the URL; if yes, it displays unread topics for those categories only (see the quoted example from Goosemoose). The check starts in Recent.php at the following line:
elseif (!empty($_REQUEST['c']))

So, what we need to do is set the value of the $_REQUEST['c'] variable to the list of categories for the currently logged in forum. That's what the code below does.

Open Recent.php in the Sources directory and find the line:
// Are we specifying any specific board?

Add just above that the following code:
// 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'] . '")';
$_REQUEST['c'] = implode(',', $row_forumList);
mysql_free_result($forumList);
}


Goosemoose, can you check if this piece of code is correct? Also, I don't know why the line below doesn't work (I commented it out in the code above), or even if it's needed or not:
$user_info['query_see_board'] .= ' AND FIND_IN_SET(c.ID_CAT, "' . $row_forumList['catList'] . '")';

If I leave the line above intact (as in the original code in page 1), an error message appears when I click on the unread posts link:



I have to comment out the line in order for Show unread posts since last visit to work.

Thank you for this mod! I have tried it on my forum and it works great. :D

I still have the error when displaying the recent topics at the top of the forum, and have it shut off as well.
SMF 1.1.1
Joomla Bridge 1.6
Joomla 1.0.12

Neol

#111
Quote from: tracilynnb on August 23, 2006, 11:03:15 AM
Thank you for this mod! I have tried it on my forum and it works great. :D

I still have the error when displaying the recent topics at the top of the forum, and have it shut off as well.

You can try changing the $user_info... line in the original code from Goosemoose, both in Load.php and BoardIndex.php, as below:

$user_info['query_see_board'] .= ' AND FIND_IN_SET(b.ID_CAT, "' . $row_forumList['catList'] . '")';

Instead of c.ID_CAT in the original mod code, the above line contains b.ID_CAT.

Try it and see if it solves your problem with the Recent Posts Bar. I don't know if this is the correct way to do it, though. Use it at your own risk.

farren

HI
I have a little problem with this mod but only under FireFox.
When I click on menu shortcut to go on a specific forum I am disconnected and I need to put again my password. If I used the normal way to go to the forum (with all categorie visible), I don't have this problem.

With IE and Opera all is fine and this mods works perfectly.

Do you have an idea?

url (french web site) : www.series-vo.com [nofollow]

Thanks

Neol

#113
farren, are you talking about the original mod code by Goosemoose, or the changes by me?

P.S. tracilynnb and others, I changed my last post. I tested the changes live and they seem to work.

farren

the original code by goosemoose.

Random

Has anyone tried upgrading to either RC2-2 or RC3 with this mod?  I see there is a security issue to be fixed, but I'm a little worried about breaking the whole setup! ;D

Neol

#116
Quote from: Random on August 24, 2006, 07:54:08 PM
Has anyone tried upgrading to either RC2-2 or RC3 with this mod?  I see there is a security issue to be fixed, but I'm a little worried about breaking the whole setup! ;D

I have tried upgrading RC2 to RC3 (in my test site in localhost) and applying the mod afterwards. This setup worked fine after some of the modifications I posted earlier in this thread. No custom themes though, no other mods or whatever.

A quick question: What is RC2-2? EDIT: Nevermind, I found out.

manuelap

Quote from: Goosemoose on January 06, 2006, 03:04:39 AM

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;' : ''));
----------------------------------------------


I did all the steps in implementing this mod, but just could not find the location of the above code in my smf.php

For some reason my first Boards opens nicely (not showing all other Boards), but whenever I try to call another board it displays no other board.... It displays one other board but that is not the correct board.

Also, I get an error message in the recent topics module "Error fetching Recent Topics: 1109 Unknown table 'c' in where clause".

I have a wrapped forum using SMF 1.1 RC2 in combination with SMF Joomla brigde 1.1.4.2.

I really would like to see this feature implemented without any flaws in my forum very soon, so if anyone is willing to assist me (even on a paid basis) and provide me with all the details how to reproduce these changes myself, I will be more than happy....

Neol

Quote from: manuelap on August 25, 2006, 01:41:19 AM
Also, I get an error message in the recent topics module "Error fetching Recent Topics: 1109 Unknown table 'c' in where clause".

The 1109 error message happened in my live forum lately. I resolved it by changing the mod code. See if my fix (reply #111 in this page) works for you.

manuelap

Thank you Olti, for that hack for the recent topics module. It indeed works now.

Still leaves me with the problem of other forums but my first one vanishing.... So if anyone knows the trick, let me know

Advertisement: