xoops forums

kaotik

Just can't stay away
Posted on: 2010/4/22 17:34
kaotik
kaotik (Show more)
Just can't stay away
Posts: 861
Since: 2004/2/19
#1

Tutorial: Add rmcommon comments to your modules

First a word of caution:
rmcommon is in alfa and should NOT be used in a production site. This tutorial is just for testing.

With that said, let's get to the tutorial.

There are 2 parts; one goes into your php file and another into your smarty template. Let's start with the php part.

PHP
open the index.php file of your module and insert this code:
//get all comments for this article/item
    
RMFunctions::get_comments('tutorial','post='.$post);
    
// Comments form
    
RMFunctions::comments_form('tutorial''post='.$post'module''');


The first line gets all comments for this item. It's a function that needs 2 vars:
'tutorial' -> this is the name of your module
'post='.$post -> this is the ID of the item. Look at the url for your module. you will probably have something like this:
http://mysite/modules/myModule/index.php?mid=8

In this case you could write your comment code as this:
//get all comments for this article/item
    
RMFunctions::get_comments('myModule','post='.$_GET['mid']);
    
// Comments form
    
RMFunctions::comments_form('myModule''post='.$_GET['mid'], 'module''');


Mind you this isn't the original code from mywords. If you want to further study this, here it is:
// Comments
// When use the common utilities comments system you can choose between
// use of Common Utilities templates or use your own templates
// We will use MyWords included templates
if ($post->getVar('comstatus')){
    
RMFunctions::get_comments('mywords','post='.$post->id());
    
// Comments form
    
RMFunctions::comments_form('mywords''post='.$post->id(), 'module'MW_PATH.'/class/mywordscontroller.php');
}


SMARTY
Now the smarty part. Open your smarty template and place this code at the bottom:
<!-- Start Comments -->
<
a name="comments"></a>
<{include 
file="db:rmc_comments_display.html"}>
<{include 
file="db:rmc_comments_form.html"}>
<!-- /
End comments -->


That's it! Simple don't you think?

deka87

Friend of XOOPS
Posted on: 2010/4/22 19:19
deka87
deka87 (Show more)
Friend of XOOPS
Posts: 1124
Since: 2007/10/5
#2

Re: Tutorial: Add rmcommon comments to your modules

thanks, kaotik! do i have to install those two modules to get comments working? also maybe any demo?
Mind anchors

bjuti

Just can't stay away
Posted on: 2010/4/22 22:34
bjuti
bjuti (Show more)
Just can't stay away
Posts: 871
Since: 2009/1/7 2
#3

Re: Tutorial: Add rmcommon comments to your modules

Great, I must try it! Tnx!

kaotik

Just can't stay away
Posted on: 2010/4/23 8:31
kaotik
kaotik (Show more)
Just can't stay away
Posts: 861
Since: 2004/2/19
#4

Re: Tutorial: Add rmcommon comments to your modules

deka87: you only need rmcommon. A demo sounds like a good ideia.

acegamer

Not too shy to talk
Posted on: 2010/4/23 18:31
acegamer
acegamer (Show more)
Not too shy to talk
Posts: 162
Since: 2005/7/11
#5

Re: Tutorial: Add rmcommon comments to your modules

Yeah a demo our some final screenshots would be great what we can expect of this hack.

Cheers!

kaotik

Just can't stay away
Posted on: 2010/4/26 18:08
kaotik
kaotik (Show more)
Just can't stay away
Posts: 861
Since: 2004/2/19
#6

Re: Tutorial: Add rmcommon comments to your modules

you can now visit my site, go to tutorials section and add comments :)
www.kaotik.biz

sarahmx

Quite a regular
Posted on: 2010/4/27 10:58
sarahmx
sarahmx (Show more)
Quite a regular
Posts: 378
Since: 2007/10/28
#7

Re: Tutorial: Add rmcommon comments to your modules

Thanks kaotik

bjuti

Just can't stay away
Posted on: 2010/4/27 13:25
bjuti
bjuti (Show more)
Just can't stay away
Posts: 871
Since: 2009/1/7 2
#8

Re: Tutorial: Add rmcommon comments to your modules

Great, tnx!

demian

Quite a regular
Posted on: 2010/5/4 1:16
demian
demian (Show more)
Quite a regular
Posts: 225
Since: 2008/4/29
#9

Re: Tutorial: Add rmcommon comments to your modules

1. what happened if you are a logged in as a registered user..do we have to input the name/email/website field ?


if no, is the username in the comment linked to xoops standard profile ?


2. how to disable email/website input

kaotik

Just can't stay away
Posted on: 2010/5/4 10:39
kaotik
kaotik (Show more)
Just can't stay away
Posts: 861
Since: 2004/2/19
#10

Re: Tutorial: Add rmcommon comments to your modules

demian: No, just the text field. Yes it's then linked to your username.
Website isn't mandatory. However you can't disable email (for anonymous users) otherwise you will have other problems, such as an anonymous user using someone else name. The email is kept confidential and is used by rmcommon as a salt to verify the name against it's email......I think....