PhpBB/Mambo Comments

This is where article comments will be kept.

PhpBB/Mambo Comments

Postby CommentBot » Sun Apr 17, 05 1:50am

Link back to the article. (Note: This is original version of article. It may have been edited. Click on link above for most recent version.)(PhpBB Mambo Comments by Chris Boylan)Page 1 of 6So, like this site, you want to have comments after all of your
articles.. However, AkoComment doesn't do exactly what you want
because you also have an integrated PhpBB forum, and you want to better
integrate the two halves not in a technical way, but in a
content-driven way - so that vistors who visit one half will find many
strings connecting the two, and hopefully will then explore both sides.

This is a step-by-step article on how to do just that. It would not be possible without the work of TIM_online's PhpBB Component for Mambo and Fluffy's Movable Type / PhpBB integration.

Before you get into this, you must understand that it requires hacking the core files of both PhpBB and Mambo, meaning that if you ever upgrade those two, you will need to do so manually, or you will lose the hacks. Or, in the case of the last Mambo upgrade - apply the upgrade, then reapply the hack. The good news is that all of the content is kept in the database, so you don't lose the comments, you just lose links to them.
Why did I do it this way? First, I don't know much about Mambots or creating Modules or Components. This will become one of those things shortly, I hope. Secondly, I wanted comments added automatically to every piece of content I created, not just things I remembered to put a mambot at the end of. There's probably a way to do that. If you know it, tell me.

So, let's go on with it...

Prerequisites:

A passing knowledge of PHP. This does not mean you need to know how to program, just that your head won't explode if you have to look around at some code when things break. Like how you forgot to add a semicolon at the end of a line.
A functioning install of Mambo and TIM_online's PhpBB Component. Make sure you have all of those integration bugs settled before you attempt this.
I also recommend Adam's new session handler, which will hopefully reduce some of the logout problems with the PhpBB component. (It still doesn't completely solve the problem) This is not actually a prerequisite, but it is nice and it's easy to make sure it works before you go hacking about.
The ability to add another table to your Mambo/PhpBB database. This will handle the linking of comments and the content they are commenting on.
A backup of that setup. I'm serious. You're going to be messing with the core files of Mambo and the PhpBB component, so you might mess things up in a way that renders your site non-functional. Good times.
An understanding that the open-source movement is one of the best damn things to happen in the computer world. Without it, I am not nearly skilled enough to pull this off. Thanks again to the people of Mambo, TIM_online, and Fluffy.Prev - Next >>View 35 CommentsPost a comment(PhpBB Mambo Comments by Chris Boylan)
CommentBot
Intermediate
Intermediate
 
Posts: 75
Joined: Mon Nov 10, 08 2:39am

1st error

Postby YoungArmy » Sun Apr 17, 05 11:09am

Hi probs installing it

1. Do I need to have that timonline component, cuz I have another phpbb component ?
... I don't have that line in components/com_forum/common.php to replace

At about line 91

----FIND----
unset($input['input']);
unset($input['not_unset']);

while (list($var,) = @each($input))
{
if (!in_array($var, $not_unset))
{
unset($$var);
}
}

unset($input);
}


I still got the frontpage runnin ( after it was messed up) by replacing the 2nd part

2. fetch all :when I run this file (as described in the install notes in read me)
Young Army Online

this error appears :

Fatal error: Call to a member function on a non-object in /home/www/web319/web319u1/html/de/includes/mambo.php on line 319

3. I didn't install the Adam's new session handler ... mainly I only installed what you described as neccessary and must.

So what could explain that after your install process I click on the Read more Link of an article and it brings me immediately to an error Debug mode in the forum ?

mmh[/url]
YoungArmy
 

Postby Chris » Sun Apr 17, 05 1:02pm

Alright, I only did this using the TIM_online phpBB component, and I didn't know of any other successful PhpBB integrations. I can't guarantee success with any other component, but you can take what I've done here and adapt it.

I'd appreciate a link to the component.

As for your current error, it is related to the problem I describe on page 5. If you look at the query, it is looking for "user_id" and not "id". "user_id" is how users are referrenced in PhpBB, but they use just "id" in Mambo, so you'll have to change it every time it appears in a database query in PhpBB files. Thus, you'll have to change that multiple times in the phpbbfetchall files. Perhaps I'll offer an edited version here on my site. Give me a few hours for that, but you can do it manually with a find and replace for now.

---- Edit ----
You can find the modified versions of the necessary mod files at http://chrisboylan.com/phpbb_mambo_comments_mod.zip.

--------------

Also it appears that my bbcode.php code was wrong too, I had to replace it with the full path to the file. Check that part of the write-up for changes.
User avatar
Chris
Site Admin
Site Admin
 
Posts: 312
Joined: Tue Nov 18, 03 1:56am
Location: Gillette, NJ

Postby Chris » Sun Apr 17, 05 3:18pm

I realize after the fact that you were linking to the portal.php file in phpbbfetchall. I have not even attemped to get this to work, and I was frankly stunned when it showed up on my site. There are so many simultaneous hacks going on here that I can't imagine all that might go wrong.

For now, this just supports the comments link and connecting to the forum. In the very near future, that might change though. I always liked the login box on the top left of the portal and so did people who visit my site.

Hopefully I'll have that fixed by the end of today.
I'm the Chris Boylan who runs Chris Boylan dot com. So there.
User avatar
Chris
Site Admin
Site Admin
 
Posts: 312
Joined: Tue Nov 18, 03 1:56am
Location: Gillette, NJ

Postby YoungArmy » Mon Apr 18, 05 11:37am

the1brother guy = young army guy ;)


Maybe you should also put the com_forum files online with the user id changed ... to make sure it is runnin like yours and to exclude that error possibility.

CU
YoungArmy
 

Postby Guest » Mon Apr 18, 05 2:29pm

I thought about that, but I think I'm going to leave the instructions up for now. I learned a lot more by following fluffy's instructions on how to do it for Movable Type than if she(?) had just posted the files. I think the end goal should be about teaching people how to hack more so than just providing it.

Kind of link the whole teaching people how to fish thing.
Guest
 

Postby YoungArmy » Mon Apr 18, 05 3:37pm

I did so took you fetch files and did id all again ... after clicking on the link he directs me to a white page tellin me this

Verfasst von Redaktion
15.04.2005
Could not obtain userdata from user table on /home/www/... .../de/components/com_forum/integrate.inc:145, SELECT * FROM mos_users WHERE id = Redaktion
YoungArmy
 

Postby Chris » Tue Apr 19, 05 12:23am

Dammit. The forum logged me out again. It appears to do so every time I create a new tab in Firefox, which sucks big time because that's how I browse (with multiple tabs of the same site).

It looks like you used your CommentBot's name instead of it's id #.

Look at the integrate.inc file, line 145:
Code: Select all
   // Need to create a new thread!
   $sql = "SELECT * FROM " . USERS_TABLE . " WHERE id = $user_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      die('Could not obtain userdata from user table on ' .
          __FILE__ . ':' . __LINE__ . ', ' . $sql);
   }


The error is referring to the database query above. It is looking in the mos_users table where the id field is = Redaktion . The only problem is that the id field is a number. If you click on any member's profile, the number at the end of the link is the id # of that user.

On page 3 of the how-to:

COMMENTBOT-ID - replace with ID # of your CommentBot.


Just make sure that in the code you put in content.html.php (specifically here the GetMessage function), you replace COMMENTBOT-ID with the id #, not the name the id # is linked with. In your case, I believe the number you are looking for is 60.
I'm the Chris Boylan who runs Chris Boylan dot com. So there.
User avatar
Chris
Site Admin
Site Admin
 
Posts: 312
Joined: Tue Nov 18, 03 1:56am
Location: Gillette, NJ

Postby YoungArmy » Tue Apr 19, 05 7:34am

Yes you were right ... I think I almost got it.

just 2 problems

- 1stprob with the html : html is active cuz I did all the hacking (http://www.phpbb.com/phpBB/viewtopic.php?p=923833) but he still writes the <br> in the forum that I use in the news typing cuz I don't have an editor.

- 2nd prob he puts Comments(0) Write comments ... twice on the page ( top & bottom) top should disappear ! and he puts it on the news index I also would like to put one on the frontpage next to read more for each article


I think it the script is not that far away from being made a component.

CU
YoungArmy
 

Postby Chris » Tue Apr 19, 05 5:26pm

First, I'm a little bit confused about your use of "he". Is there someone else you are coding with? Or is it just a language thing?

I suspect the first problem is because you either haven't added the necessary html tags on the phpBB admin configuration page, (they need to be listed even if only the admin uses them), or the hack is looking for an admin and you bot is not one.

2 -- This happens when php outputs something in Mambo, (i.e. echo) . If you put an echo command in the content.html.php file, it will appear at the top of the page. However if you make a string and then concatenate it to the $row->text array, it will pop out at the end.

To test this, write this in the middle of the stuff you added in content.html.php:
Code: Select all
echo "This will appear at the top";
$bottom = "This will appear at the bottom";
$row->text = $row->text.$bottom;

and the text will appear where it says it will. Somewhere you have the commands outputting the Comments link to an echo or printf or something I suspect.
I'm the Chris Boylan who runs Chris Boylan dot com. So there.
User avatar
Chris
Site Admin
Site Admin
 
Posts: 312
Joined: Tue Nov 18, 03 1:56am
Location: Gillette, NJ

Postby YoungArmy » Wed Apr 20, 05 12:54pm

Language thing I'm pretty embarrassed that's what comes out after a direct translation from Luxembourgish to English... we use to personalise material things (but colloquial)

Well the first worked out I simply forgot to add the br tag.

2nd prob did not work out everything appears at the top that you gave me.

My code looks like this

Code: Select all
id, 23, 76, "$row->title", "".$row->text, 0, NOTIFICATION-ID);

$commentcount = 0;
if ($thread_id = GetThread("$idvar")) {
$thread = phpbb_fetch_topics($thread_id);
$commentcount += ($thread?$thread[0]['topic_replies']:0);
}

$viewcomment = "Lese ".$commentcount . " Kommentare".($commentcount != 1?'':'') . "";

$postcomment = "Kommentiere";

$row->text = $row->text.$viewcomment.$postcomment;
         } else
      {
      }


         // displays Item Text
         echo $row->text;$bottom;
         ?>


after that it says

Code: Select all
      
      


I am really a php rookie but is there no possibility that I don't use echo but sth like HTML_content instead.

mmh

The problem is; it also appears at the top of the news index where nothing at all should appear.
YoungArmy
 

Postby Chris » Thu Apr 21, 05 3:19pm

A) You should change the NOTIFICATION-ID to the id number of your user in the forum, i.e. the admin. That way you will get emails when people reply. It may create error messages if you leave it that way, but I'm not sure.

B) What is $bottom? It is the last thing to appear on the first batch of code. It also appears after a semicolon, which indicates the end of a line to PHP. I don't suspect this is right.

C) If it is appearing on non com_content pages, then it may have been accidentally added to your template file when you set up the includes there.

D) The way I set this up is so that to Mambo everything looks completely normal. You generate all the comment code, and then append it to whatever the text of the article it already pulled is.

For instance:

Code: Select all
$append = "<br>This is appended."
$row->text = $row->text.$append


Would add the line "This is appended" to the end of every article. The content of each article is kept in the $row->text array. Then, however Mambo puts it out, that line will appear at the end.

Try adding the $append variable, like above, to the code just before $row->text, and then change the line to
Code: Select all
$row->text = $row->text.$viewcomment.$postcomment.$append;

and see what happens. Does the appended line appear only at the bottom , or the top too?
I'm the Chris Boylan who runs Chris Boylan dot com. So there.
User avatar
Chris
Site Admin
Site Admin
 
Posts: 312
Joined: Tue Nov 18, 03 1:56am
Location: Gillette, NJ

Postby YoungArmy » Thu Apr 21, 05 3:33pm

Well I hope I got you right ... that's the way the code looks like now :
Code: Select all
   Note:  I messed around in PhpBB and lost this code.
--Chris



But mambo puts it all out at the bottom and the top ... you can see that here : Really long link
YoungArmy
 

Postby Chris » Thu Apr 21, 05 10:21pm

Alright. That's really confusing. I can't think of a good reason why it is doing that.

So, you're left with the toubleshooting task I had quite a few times. Basically, try commenting out different sections of content.html.php or the include files until it disappears. Now, some of the commenting will break basic functionality, but just for a short time.

Comment out
Code: Select all
/** Comment out
      multiple lines **/
or
// a single line

all of the stuff we've added,
Code: Select all
      $optionvar = mosGetParam( $_REQUEST, 'option', "" );
thru
$postcomment = "Kommentiere";


except for the $append line. See if the append line is output twice. If no, then the problem is inside the comments. If it happens twice, start commenting out the included files in the content.html.php and template file. When you figure out the file causing the trouble, open it and start narrowing down the problem until you can cut it down to a single line or two. This is basically how I wrote this . Trial and lots of error.
Last edited by Chris on Sat May 21, 05 1:21am, edited 1 time in total.
I'm the Chris Boylan who runs Chris Boylan dot com. So there.
User avatar
Chris
Site Admin
Site Admin
 
Posts: 312
Joined: Tue Nov 18, 03 1:56am
Location: Gillette, NJ

Postby YoungArmy » Fri Apr 22, 05 1:15pm

In fact if I comment out what you told me to comment out he just tells me error :

Code: Select all
Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/www/web319/web319u1/html/de/components/com_content/content.html.php on line 1369



the code should look like this right ?:



Code: Select all
id, 23, 73, "$row->title", "Link back to the article. (Note:  This is original version of article.  It may have been edited.  Click on link above for most recent version.)(PhpBB Mambo Comments by Chris Boylan)".$row->text, 0, 73);

$commentcount = 0;
if ($thread_id = GetThread("$idvar")) {
$thread = phpbb_fetch_topics($thread_id);
$commentcount += ($thread?$thread[0]['topic_replies']:0);
}


$viewcomment = "Lese ".$commentcount . " Kommentar".($commentcount != 1?'e':'') . "";

$postcomment = "Kommentiere"; 
multiple lines **/

$append = "This is appended." ;
$row->text = $row->text.$postcomment.$append;
         } else
      {
      }


         // displays Item Text
         
         
         echo  $row->text;
         ?>
YoungArmy
 

Next

Return to Comments for Chris Boylan .com articles

Who is online

Users browsing this forum: No registered users and 0 guests

cron