Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 [2] 3

Author Topic: [WIP] Threaded comments  (Read 3227 times)

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [WIP] Threaded comments
« Reply #15 on: October 11, 2010, 10:50:57 AM »

hey all :)

@ nukpana
karma for endless support and develoment for sNews.

i was working on a multi thread comment mod as well,
my goal is multi level threaded comment system.

this is how it looks in my dev server,

Uploaded with ImageShack.us

i alter the comment table add parentid, level and title fields

the core functions to render the tree
Code: [Select]
<?php
function ctree($mnu=''){
global $articleSEF$_ID;
$artid=retrieve('id','articles','seftitle',$articleSEF);

$s='SELECT id,articleid,name,comtitle,url,comment,time,approved, parentID, 
level from comments 
where articleid='
.$_ID.
order by time'
;

$sq=mysql_query($s);
$sn=mysql_num_rows($sq);
if($sn<1){ return; }

$menuData = array(
'items' => array(),
'parents' => array()
);

$x=1;
while ($menuItem mysql_fetch_assoc($sq)) {
$menuData['items'][$menuItem['id']] = $menuItem;
$menuData['parents'][$menuItem['parentID']][] = $menuItem['id'];
}
$boxo 
'<div id="comments" class="commentshort">'.
'<div><strong>'.l('comments').'</strong></div>'.
'<div class="tree">';

$boxe '</div></div>';

// output the TREE
echo $boxo;
echo buildTREE(0$menuData);
echo $boxe;
}

// TREE builder function, parentId 0 is the root
function buildTREE($parentId$menuData) {
    if (isset(
$menuData['parents'][$parentId])){
foreach ($menuData['parents'][$parentId] as $itemId) {
$id=$menuData['items'][$itemId]['id'];
$name=$menuData['items'][$itemId]['name'];
$comtitle=$menuData['items'][$itemId]['comtitle'];
$text=$menuData['items'][$itemId]['comment'];
$time=$menuData['items'][$itemId]['time'];
$level=$menuData['items'][$itemId]['level'];
$url=$menuData['items'][$itemId]['url'];
if($s!=1) { 
$indnt=str_repeat('&bull;',$level+1) ; 
}

echo '<div class="te">';

if($level 1){
$marg '0px';
$sty 'fp';
} else {
$marg = ($level*6).'%';
$sty '';
}

if(__lang!='en'){
$mdir='right';
} else {
$mdir='left';
}

echo '<div id="'.l('comment').$id.'">';
echo '<div class="combox '.$sty.'" style="margin-'.$mdir.':'.$marg.';">';
echo '<div class="comhead">';
echo'<h3>'.l('title').': '.$comtitle'</h3>';
echo !empty($url) ?
''.l('by').'<a href="'.$url.'" title="'.$url.'" rel="nofollow">
<b>'
.$name.'</b></a> ' l('by').'<b>'.$name.'</b>';  
echo ' '.$indnt;
echo ', <span>'.l('on').' '.$time'</span>';

echo'</div>';

echo '<div class="comment">'
.$text.
'</div>';

$srid=$id;
$srlevel=$level;
cmntBttns($srid,$srlevel);

echo '<div class="clearer"> </div>';
echo '</div>';

// find child recursive
buildTREE($itemId$menuData);

echo '</div>';
echo '</div>';
}
}
}
?>






i dont know if this approach is the best for multitreaded multilevel tree,
i would love to know if you think this could be done better more efficient.

feel well.


awesome day to all
« Last Edit: October 11, 2010, 11:03:03 AM by mosh »
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: [WIP] Threaded comments
« Reply #16 on: October 12, 2010, 11:44:41 AM »

Mosh, good for you for taking a stab at this too.  Not sure about efficiency. Efficiency can be looked at from any aspect and can be debated (to a point). 

I take it, you are storing the level in the database in a hierarchical fashion - what if you delete a comment? The whole tree underneath would need to be re-built.  I have that flaw in my system as I didn't account for it.  If you have a solution, great. For me, a solution, is possibly add a new column for deleted items and not have it shown in any comment query.  This would add to the complexity of the modification, so I am researching another solution
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [WIP] Threaded comments
« Reply #17 on: October 12, 2010, 12:48:27 PM »

@ nukpana
karma for endless support and develoment for sNews.
+1

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [WIP] Threaded comments
« Reply #18 on: October 12, 2010, 01:33:26 PM »

@nukpana

if i delete a comment it will delete the child comments as well,
the solution is not to delete the comment but to edit and delete the content for that comment,
that way there is no need to rebuild the levels.

the comment level is saved to db and is fixed.

the logic is based on vBulletin forum system.

there is no need for comment pages and pagination,
all comments for the article will display on one page.

in my mod i target the comment option for regiser user only,
just like forum system.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [WIP] Threaded comments
« Reply #19 on: October 12, 2010, 05:53:45 PM »

@nukpana
in my mod i target the comment option for regiser user only,
just like forum system.
???
can you tell us more about this, dear Moshe?

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [WIP] Threaded comments
« Reply #20 on: October 12, 2010, 09:14:17 PM »

@nukpana
in my mod i target the comment option for regiser user only,
just like forum system.
???
can you tell us more about this, dear Moshe?

hey sven :)
i am working on user system mod for snews and this threaded comment system to act as a forum,
most forums ask visitors to register if one want to write posts and comments.

i love the way vBulletin forum system works and wanted to use snews for the task.

the threaded comments is working great, im still messing with the user system.

will use the categories and sub as forums and articles as posts,
each post can have multi threaded comments,
all comments will display under the post content in a tree view,
the system will allow only to registered users ( members ) to post new posts and comment all.
only admin can make new forums ( categories and subs ).

awesome night

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [WIP] Threaded comments
« Reply #21 on: October 26, 2010, 02:45:38 AM »

@nukpana

if i delete a comment it will delete the child comments as well,
the solution is not to delete the comment but to edit and delete the content for that comment,
that way there is no need to rebuild the levels.

Just passing ... excellent, don't even need to be deleted(the message will remain intact, you don't know when you will need it :P ), only marked as deleted then, a message displayed instead (php role here):
"Message deleted" or something which does fit better... maybe a list of messages to chose from (another field in record?):
 - Message marked as spam
 - Message deleted by owner
 - Message deleted
 - ... and so on...

A good day to everyone and best regards!
Vasi
« Last Edit: October 26, 2010, 03:30:16 AM by funlw65 »
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [WIP] Threaded comments
« Reply #22 on: October 26, 2010, 04:20:17 PM »

Thanks and Karma to Jason (Nukpana) for his Threaded Comments project!  :)
I installed it in my 'enhanced' snews 1.7 package yesterday and it is working well as intended.
My next step is to apply Matt Jone's Gravatar Mod to it.

I particularly appreciate the way the project is contained in one single file. This will make it very simple to install it as a module in a future modular version of sNews.

I am working on user system mod for snews and this threaded comment system to act as a forum. Most forums ask visitors to register if one want to write posts and comments.

I love the way vBulletin forum system works and wanted to use snews for the task. The threaded comments is working great, im still messing with the user system.

@ Mosh... I am really looking forward to your sNews-based Forums project. This, along with Jason's Threaded Comments project, are excellent examples of how sNews can be customized to provide great functionality.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [WIP] Threaded comments
« Reply #23 on: October 28, 2010, 05:06:14 PM »

@vasi
hi, good to see you back,
say hello to family for me please.

@key
Jason deserve all the good karma, doing so much work for sNews and the members.
thank you Jason.

will be happy to share the project,
need to do some more work befor it can be released.

karma for you keyrocks for you deserve it as well for your support.


awesome night/day to all

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [WIP] Threaded comments
« Reply #24 on: February 01, 2012, 04:17:22 PM »

will be happy to share the project,
need to do some more work befor it can be released.

Hi Mosh.... It has been a long time since we last taked about this project of yours. Did you ever complete the project... are you ready to share it yet?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [WIP] Threaded comments
« Reply #25 on: February 01, 2012, 09:07:28 PM »

Hi Key,
How are you doing ?

I had some progress with the project, had to write user system ( meny functions for user, got complex, im still in that stage ).
the last year i did not have the right mind to code much.

The code i have now is very messy, meny files.
I will install the mod with a simple login on a cleane one file snews 1.7 and share.

I may try to install the mod on the snewsMU to bypass the need to write new user system from scrach.

hope it will not take long :)

awesome day

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [WIP] Threaded comments
« Reply #26 on: February 02, 2012, 09:12:00 PM »

I'm doing fine Mosh... I have not been coding sNews much for the past year either. When I get time I work on my "MysNews" project, very many mods on the current 1.7 (on the downloads page) with a whole new administration system using tabbed panels instead of panels one under the other. I have it finished in Single-User but have not cleaned up the code yet. Next I want to make it for multiple-users too.

I was thinking I would also like to add your forums mods when you get finished with them. Do you have it functioning OK yet?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

mosh

  • Hero Member
  • *****
  • Karma: 77
  • Posts: 510
  • Awesome day :)
    • cms-zen
Re: [WIP] Threaded comments
« Reply #27 on: February 03, 2012, 10:20:47 AM »

Yes, the comments function works fine,
the coding was done with wide changes to snews functions and with user system.
I started to add the comments system into sNewsMU1.7 with minimum changes to the core as possible,
and changes needed to the comment system to work with the DB.

Your "MysNews" MU sounds intersting, would be perfect with the tree comments system.  :)

I may install a test website with my current code to see how it works in real world internet.

Awesome day

walkie

  • Newbie
  • *
  • Karma: 0
  • Posts: 16
  • sNews lover <3
    • Jaded.dk
Re: [WIP] Threaded comments
« Reply #28 on: July 30, 2012, 09:44:51 AM »

So I am trying to implement the mod from this post http://snewscms.com/forum/index.php/topic,9461.msg65822.html#msg65822, to my site.

I am able to reply to a comment, but when I do that, it's not being indentet, and is just inserted at the bottom, instead of under the replied post. I can see in my DB that it gets the right parent id, so it's like the <div> doesn't get the right class?!?

I have included the mod.comment-threads.php in my index.php, out commented the function comment() in snews.php, created 'parent' in TABLE comments.

Hope that someone can help me out :)

You can see it live on my site here:
http://jaded.dk/3

And my files here:
http://jaded.dk/index.php.txt
http://jaded.dk/mod.comment-threads.php.txt
http://jaded.dk/snews.php.txt


Thanks
-Morten
« Last Edit: July 30, 2012, 09:51:57 AM by walkie »
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: [WIP] Threaded comments
« Reply #29 on: July 31, 2012, 06:30:08 PM »

It doesn't appear to be running on your site.  As you can see on mod.comment-threads.php, the first function has CSS & Javascript that doesn't show when you view the source of your site. 
Logged
Pages: 1 [2] 3