News:

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

Main Menu

Joomla-SMF Recent Topics doesn't work when logged

Started by hefesto, February 05, 2006, 07:30:12 AM

Previous topic - Next topic

hefesto

Joomla version:               1.0.7 stable
SMF version:                  1.1 RC2
Bridge version:                3.20, 1.1 RC2 compatible
Recent Topics version:     1.6.1
URL:                             http:[//]salamancresa[dot]iespana[dot]es/joomla/

I've used that configuration at other sites, and always worked fine. The problem I'm having now is that the recent topics module doesn't display any topics when logged in, but works correctly when logged out (I've tested from different computers and with both Firefox and IE browsers ).

The config of the server is as follows:

MySQL:             5.0.18-debug
PHP:                 4.4.2 (with Apache)
Safe Mode:        ON  >:(
Zlib:                 Not supported (had to install everything from directories)  >:( >:(

Any ideas about what can be happening?

Thanks.

NOTE: For non spanish speakers, the title of the "recent topics module" is "Últimos mensajes en el foro". You'll see it at the main page, in the middle.

Kindred

where did you get that version of the recent topics module?
I don't recognize the version number...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

hefesto

To be truth I don't remember at this moment, but I think I got it from Joomlahacks. Here you have de code of the .php file:

<?php
/**
* @version $Id: mod_smf_recent_topics.php,v 1.4 2006/01/08 16:10:29 Wolverine Exp $
* @package Joomla
* @copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Joomla is Free Software
*/

/** ensure this file is being included by a parent file */
defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* 1.5 params-get() second parameter is a default (-Wolverine)*/
//These defaults are identical to the defaults set in mod_smf_recent_topics.xml
$board  $params->get'board');
$limit  $params->get'limit');
$datetime  $params->get'datetime');
$numchar  $params->get'numchar'10 );
$namedisplay  $params->get'namedisplay');
$moduleclass_sfx            $params->get'moduleclass_sfx''' );
$scroll  $params->get'scroll'0);
$scrolldirection            $params->get'scrolldirection''up');
$scrollamount       $params->get'scrollamount'2);
$scrolldelay =      $params->get'scrolldelay'20);
/*1.6.1 Use our own smf prefix*/
$smf_tprefix =                $params->get'smf_tprefix''' );

/* 1.5 User does not need to save to initialize parameters if they want the defaults (-Wolverine)*/

//Include the JoomlaSMF bridge variables 
require($mosConfig_absolute_path."/administrator/components/com_smf/config.smf.php");
/* 1.3 use $smf_tprefix instead of $db_prefix(-Wolverine)*/
global $database$context$txt$settings$ID_MEMBER$user_info$mosConfig_sef;


/*1.6.1 Return immediately if smf table prefix isn't set (-Wolverine)*/
if(empty($smf_tprefix))
{
     echo 
"<b>Please configure the SMF table prefix for this module!</b>";
     return 
false;
}

/* 1.5 smfItemid is already stored in $mosurl in config.smf.php (-Wolverine) */
/*1.6.1 smfItemid is not in all bridges, so the query returns(-Wolverine)*/
$database->setQuery("SELECT id FROM #__menu WHERE link = 'index.php?option=com_smf'");
if (
$result $database->query()) {
$row mysql_fetch_object($result);
$smfItemid $row->id;
}
$smfurl "index.php?option=com_smf&amp;Itemid=" $smfItemid."&amp;";

$exclude_boards = array();
$output_method 'echo';

// Find all the posts.  Newer ones will have higher IDs.  
/*1.3 - Find only the posts this user is allowed to see(-Wolverine)*/
/*1.4 - The whole db_query stuff wasn't working in Joomla 1.0.4 so I changed the method to use setQuery followed by query (-Wolverine)*/
/*1.6 The table $smf_tprefix}log_topics fields changed in SMF 1.1RC2, specifically log_Time was changed to ID_MSG.  Many 
           SQL changes were included in this fix. (-Wolverine)*/
$database->setQuery("
SELECT
mem.realName,
m.posterTime,
m2.subject,
t.ID_TOPIC,
t.ID_MEMBER_UPDATED,
t.ID_LAST_MSG,
m.ID_MSG_MODIFIED,
m.ID_BOARD,
b.name AS bName,
t.numReplies,
m.posterName AS memberName, 
. ($user_info['is_guest'] ? "0" "IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1") . " AS new_from
FROM 
(
{$smf_tprefix}members AS mem, 
{$smf_tprefix}topics AS t, 
{$smf_tprefix}messages AS m, 
{$smf_tprefix}messages AS m2, 
{$smf_tprefix}boards AS b
. (!$user_info['is_guest'] ? "
LEFT JOIN 
{$smf_tprefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN 
{$smf_tprefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" "") . ")
WHERE 
t.ID_BOARD = m.ID_BOARD
AND t.ID_BOARD = b.ID_BOARD" 
. (empty($exclude_boards) ? '' "
AND t.ID_BOARD NOT IN (" 
implode(', '$exclude_boards) . ")") . "
AND t.ID_LAST_MSG = m.ID_MSG
AND t.ID_FIRST_MSG = m2.ID_MSG
AND mem.memberName = m.posterName 
AND 
$user_info[query_see_board]
ORDER BY 
m.ID_MSG DESC
LIMIT 
$limit");

$posts = array();
/* 1.5.1 Do not use $this outside object context (-Wolverine) */
if ($result $database->query())
{
while ($row mysql_fetch_assoc($result)) {
// Censor the subject.
censorText($row['subject']);

/*1.6 The structure of the link to a message has changed in SMF 1.1 RC2.  (-Wolverine) */
$posthref sefRelToAbs($smfurl 'topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . '#new');
$posthref = (substr($posthref,strlen($posthref)-1)=="/" substr($posthref,0,strlen($posthref)-1) : $posthref );


// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $smfurl '?board=' $row['ID_BOARD'] . '.0',
'link' => '<a href="' sefRelToAbs($smfurl 'board=' $row['ID_BOARD'] . '.0').'">' $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
/*1.6 poster was changed to member to follow SMF methods (-Wolverine)*/
'member' => array(
'username' => $row['memberName'],
'name' => $row['realName'],
'id' => $row['ID_MEMBER'],
'href' => !empty($row['ID_MEMBER']) ? $smfurl '?action=profile;u=' $row['ID_MEMBER'] : '',
'link' => !empty($row['ID_MEMBER']) ? '<a href="' $smfurl '?action=profile;u=' $row['ID_MEMBER'] . '" title="' $txt[92] . ' ' $row['memberName'] . '">' . ($namedisplay == $row['realName'] : $row['memberName']) . '</a>' : ($namedisplay == $row['realName'] : $row['memberName'])
),
'subject' => $row['subject'],
'short_subject' => strlen(un_htmlspecialchars($row['subject'])) > 25 htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 022) . '...') : $row['subject'],
'time' => timeformat($row['posterTime']),
'timestamp' => $row['posterTime'],
'href' => $posthref,
/* 1.6 link compatibility changes (-Wolverine)*/
'link' => '<a href="' $smfurl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . '#new">' $row['subject'] . '</a>',
/* 1.6 Use the msg id to determine if the post is new (-Wolverine)*/
'new' => $row['new_from'] <= $row['ID_MSG_MODIFIED'],
'replies' => $row['numReplies']
);
}
/*1.4.1 Free only if we got a result (-Wolverine)*/
mysql_free_result($result);
}

// Just return it.
/* 1.5 Use strcmp, much better method for string comparisons (-Wolverine)*/
if (strcmp($output_method'echo') != || empty($posts))
return $posts;

/* 1.5 PHPNuke marquee scrolling (-Wolverine)*/
//PHPNuke scrolling adapted from Forums Scroll V2 
//Original Author: Telli
//E-mail: [email protected]
//Home Page: www.Codezwiz.com
if($scroll)
echo '<marquee behavior="scroll" direction="',$scrolldirection,'"', ($scrollamount != " scrollamount=\"$scrollamount\"" ""),'',($scrolldelay != 0  " scrolldelay=\"$scrolldelay\"" ""),' onmouseover=\'this.stop()\' onmouseout=\'this.start()\'>';

echo 
'<ul class="latestnews',$moduleclass_sfx,'">
'
;
foreach ($posts as $post) {

echo '<li class="latestnews',$moduleclass_sfx,'">';
echo '<a class="latestnews',$moduleclass_sfx,'" href="'$post['href'], '">';

if ($board == && !empty($board)) {
echo '<i>',$post['board']['name'], '</i> : ';
}

/* 1.6 post['href'] contains the link to a new post as well, use it (-Wolverine) */
echo ($numchar != '' substr($post['subject'],0,$numchar).(strlen($post['subject']) > $numchar '...' '') : $post['subject']) , '</a> (',
$post['replies'], ') '$txt[525], ' ', ($mosConfig_sef == '1' str_replace(";","/",$post['member']['link']) : $post['member']['link']) , '
'
, ($post['new'] ? '<a href="' $post['href'] . '"><img src="' $settings['images_url'] . '/' $context['user']['language'] . '/new.gif" alt="' $txt[302] . '" border="0" /></a>' '');

if ($datetime == && !empty($datetime)) {
echo ' - ',$post['time'];
}
echo "</li>\n";
}
echo 
'</ul>';

if(
$scroll)
echo '</marquee>';
?>

Kindred

there is no guarantee that Joolmahacks modules will work with Orstio's bridge...   Actually, there is a good chance that such modules will NOT work.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

hefesto

As I said in my first post, I'm using exactly the same configuration (Joomla+SMF+Bridge+This module) with other sites, and it's working fine. I'm not really sure about where I got the module from. Which one would you recommend me?

Orstio

Do you have SMF and Joomla in different databases?

Orstio

You can probably get rid of this:

// Just return it.
/* 1.5 Use strcmp, much better method for string comparisons (-Wolverine)*/
if (strcmp($output_method, 'echo') != 0 || empty($posts))
return $posts;


That's a modified piece of code from SSI.php, which returns an array instead of echoing output for the creation of more advanced SSI features.  Unfortunately, it looks like the author of the module didn't understand that, and also put a return outside a function....  There's really no telling where that is returning, or what it's ever going to do with the $posts array.

hefesto

Hey Orstio, I'm glad of having you as a registered user  ;D. Thanks for taking so much interest.

Unfortunately, I supressed that piece of code and everything remains the same.

Quote from: Orstio on February 05, 2006, 01:14:52 PM
Do you have SMF and Joomla in different databases?

Nop. They're in the same one. Only one DB allowed  :(. But I've installed it in one DB at other hosts, and it worked fine. I'm suspecting it could be something related with the top banner the host inserts. I asked them to turn Zlib support on, and they did, but after a few hours they turned it off again, and told me that it was causing problems with the banner. Maybe it causes problems with everything  >:(.

Thanks again for your help.

Orstio

Have you tried this module instead:

http://www.simplemachines.org/community/index.php?action=dlattach;topic=25718.0;attach=13224

You probably won't be able to publish it on the forum page, but it should work on all other pages.

hefesto

This module works great. And I'll say more: this one is the one I was looking for. I saw it in a friend's page before I made my own Joomla portal, and when I installed the module I got from (probably) Joomlahacks I saw that everything was alligned in the middle, while my friend's one was like the one you provided  ;D.

Thanks a lot.

hefesto

Would it be possible to allign date and time completely to the right in this recent topics module?

<?php

global $context$txt$scripturl$mosConfig_dbprefix$mosConfig_db$db_name;

mysql_select_db($mosConfig_db);
$sql "SELECT id FROM ".$mosConfig_dbprefix."menu WHERE link='index.php?option=com_smf'";

$result mysql_query ($sql);

$row mysql_fetch_array($result);

$myurl $_SERVER['PHP_SELF'] . "?option=com_smf&Itemid=" $row[0]."&";

$scripturl $myurl;

$num_recent 5;
mysql_select_db($db_name);
ssi_recentTopics($num_recent);
mysql_select_db($mosConfig_db);


?>


Kindred


<?php

global $context$txt$scripturl$mosConfig_dbprefix$mosConfig_db$db_name;

mysql_select_db($mosConfig_db);
$sql "SELECT id FROM ".$mosConfig_dbprefix."menu WHERE link='index.php?option=com_smf'";

$result mysql_query ($sql);

$row mysql_fetch_array($result);

$myurl $_SERVER['PHP_SELF'] . "?option=com_smf&Itemid=" $row[0]."&";

$scripturl $myurl;

$num_recent 5;
mysql_select_db($db_name);
echo 
'<div align="right">';
ssi_recentTopics($num_recent);
echo 
'</div>';
mysql_select_db($mosConfig_db);

?>

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

hefesto

Mmmmm, adding that takes everything to the right, like this:

                                 [forum name1]Topic name1 by Poster1       Today at 05:24:25 AM
               [forum name2]Topic name 2 a bit longer by Poster1       Today at 05:24:25 AM
                                       [forum3]Topic name 3 by Poster 4 Yesterday at 05:24:25 AM


What I would like is having forum name, topic name and poster name to the left (exactly as it is right now) and taking only date and time to the right... Something like this:

[forum name1]Topic name1 by Poster1                                       Today at 05:24:25 AM
[forum name2]Topic name 2 a bit longer by Poster1                     Today at 05:24:25 AM
        [forum3]Topic name 3 by Poster 4                                     Today at 05:24:25 AM

Thanks for your quick reply, Kindred.

Kindred

in that case...  it's not nearly as simple...

you will have to open the SSI.php, copy out the recentTopics function and past it into the module, above the $num_recent = 5; line...

Once you have that pasted in, you can edit the layout as you desire...
(BTW: rename the function to something else... and then rename the line ssi_recentTopics($num_recent); to reflect your new function name...)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: