Forums / Cotonti / Extensions / Recent comments

KillerSneak
#1 2009-07-22 01:54
I'm still using the one made for seditio, only thing is that if someone posts a comment and i get the update e-mail not entitlement is given for the e-mail

http://www.t3-design.com/latest-comments-in-sed/comment-page-1/ <- I'm not using this one as i have customized mine a bit so i don't think it's original anymore.

I want to know if anybody is willing to help me port it to Cotonti - I for one find it very usefull to have the recent comments on the frontpage (also as follow-up and to see what interests the community the most). I think the recent items code/setup can be used to do this?

Added 14 minutes later:

<?PHP

/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/recentcomments/recentcomments.php
Version=110
Updated=2009-mar-14
Type=Plugin
Author=Neocrome
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=recentcomments
Part=main
File=recentcomments
Hooks=index.tags
Tags=index.tpl:{PLUGIN_LATESTCOMMENTS}
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]

==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

/* ============ MASKS FOR THE HTML OUTPUTS =========== */

$cfg['plu_mask_comments'] = " %3\$s"." %1\$s"." ".$cfg['separator']." "."%2\$s"."<br />";
// %1\$s = Link to the comment
// %2\$s = Author
// %3\$s = Date

$plu_empty = $L['None']."<br />";

/* ================== FUNCTIONS ================== */

function sed_get_latestcomments($limit, $mask)
{
//global $L, $db_com, $usr, $cfg, $plu_empty;
global $L, $db_com, $db_pages, $usr, $cfg, $sed_cat, $plu_empty;//motor2hg


$sql = sed_sql_query("SELECT MAX(com_id) AS _id, MAX(com_date) AS _date FROM $db_com WHERE com_isspecial=0 GROUP BY com_code ORDER BY _date DESC LIMIT $limit");

$com_latest = array();
while($row = sed_sql_fetcharray($sql)) $com_latest[] = $row['_id'];

$sql = sed_sql_query("SELECT com_id, com_code, com_date, com_author FROM $db_com WHERE com_id IN('".implode("','",$com_latest)."') ORDER BY com_date DESC");


while ($row = sed_sql_fetcharray($sql))
{
/*$com_code = $row['com_code'];
$j = substr($com_code, 0, 1);
$k = substr($com_code, 1);*/
$com_code = $row['com_code'];//motor2hg

$z = $row['page_title'];//motor2hg

$j = substr($com_code, 0, 1);//motor2hg

$k = substr($com_code, 1);//motor2hg

switch($j)
{
//case 'p':
//$lnk = "<a href=\"page.php?id=$k&comments=1#c".$row['com_id']."\">".$L['Page']." #".$k."</a>";
//break;
//////////////////////////////motor2hg/////////////////////////////
                case 'p':
                $sql2 = sed_sql_query("SELECT page_title FROM sed_pages WHERE page_id = $k LIMIT 0, 30");
                while ($row2 = sed_sql_fetcharray($sql2))
                { $page_title = $row2['page_title']; }
                $lnk = "<a href=\"page.php?id=$k&amp;comments=1#c".$row['com_id']."\">"." \"".$page_title."\"</a>";
                break;
///////////////////////motor2hg/////////////////////////////////////
case 'v':
$lnk = "<a href=\"javascript:polls('".$k."&comments=1#c".$row['com_id']."')\">".$L['Poll']." #".$k."</a>";
break;

}
$res .= sprintf($mask, $lnk, sed_cc($row['com_author']), date($cfg['formatyearmonthday'], $row['com_date'] + $usr['timezone'] * 3600));
}

$res = (empty($res)) ? $plu_empty : $res;

return($res);
}


/* ============= */

if (!$latestcomments && $cfg['plugin']['recentcomments']['maxcomments']>0)
{
$latestcomments = sed_get_latestcomments($cfg['plugin']['recentcomments']['maxcomments'], $cfg['plu_mask_comments'] );
//sed_cache_store('latestcomments', $latestcomments, 5); 

}

$t-> assign(array(
	"PLUGIN_LATESTCOMMENTS" => $latestcomments,
	));
?>



Added current plugin code.[/]

Added 27 seconds later:

Does anybody else see the lose closing tag above? [/] ?? shouldn't be there?
This post was edited by KillerSneak (2009-07-22 02:12, 14 years ago)
Trustmaster
#2 2009-07-22 02:32
I think there is recentcomments plugin in the repository which has been ported. You can download it here.
May the Source be with you!
KillerSneak
#3 2009-07-22 02:36
Does this mean that it works? Or that I'm going to test it (not that i mind, but for me to prepare / backup before I'm going to test it :) )

Added 3 minutes later:

error

Fatal error: Uncaught exception 'Exception' with message 'Block RECENTCOMMENTS is not closed correctly in ./plugins/recentcomments/tpl/recentcomments.tpl' in /home/donotarg/public_html/system/xtemplate.php:171 Stack trace: #0 /home/donotarg/public_html/system/xtemplate.php(39): XTemplate->restart('./plugins/recen...') #1 /home/donotarg/public_html/plugins/recentcomments/recentcomments.index.php(32): XTemplate->__construct('./plugins/recen...') #2 /home/donotarg/public_html/system/core/index/index.inc.php(44): include_once('/home/donotarg/...') #3 /home/donotarg/public_html/index.php(20): require_once('/home/donotarg/...') #4 {main} thrown in /home/donotarg/public_html/system/xtemplate.php on line 171

Added 21 minutes later:

fixed:

<!-- END: RECENTCOMMENTS-->

should be

<!-- END: RECENTCOMMENTS -->

Added 6 minutes later:

Okey tried it.

It's nice to have the ajax effect just some notes:

No poster name of the comment? (see code above of old version)
Want to be able to chnage the date format.
This post was edited by KillerSneak (2009-07-22 03:07, 14 years ago)
SunChase
#4 2009-07-22 03:32
it would be great if someone made a Recent comments by user plugin...
[url=http://ka13.orgfree.com]KA13[/url] - The essence of creativity
pieter
#5 2012-09-22 05:43

Does this exists for Siena? I can't port it, I'm to stupid (for php) :-)

Added 10 minutes later:

In the comments plugin, you can add the tag {PAGE_ROW_COMMENTS} into recentitems.tpl, but this is not for the index-page.

... can we help you ...
This post was edited by pieter (2012-09-22 05:54, 11 years ago)
Kort
#6 2012-09-22 08:13

Pieter: we'll announce the Recent Comments plugin along with a bunch of others soon. No need for porting.

SED.by - создание сайтов, разработка плагинов и тем для Котонти
pieter
#7 2012-09-22 08:35

Perfect. What is soon?

... can we help you ...
Trustmaster
#8 2012-09-22 11:19

There's a port I made 10 months ago actually.

May the Source be with you!
pieter
#9 2012-09-23 05:53

Thanks,

The date is not showing. 

"RECENTCOMMENTS_ROW_DATE" => cot_date($cfg['datetime_short'], $row['com_date'] + $usr['timezone'] * 3600),

Is this still correct after the changes in Siena?

... can we help you ...
Trustmaster
#10 2012-09-23 15:05

It needs an update:

"RECENTCOMMENTS_ROW_DATE" => cot_date('datetime_short', $row['com_date']),

 

May the Source be with you!
Uch
#11 2012-11-08 12:48

Предлагаю сделать небольшие изменения, что бы получить еще и кол-во комментариев:

1.В строке 45 заменим SQL запрос на:

$sqlcom = $db->query("SELECT MAX(com_id) AS _id, MAX(com_date) AS _date, COUNT(com_code) AS _count, com_code FROM $db_com GROUP BY com_code ORDER BY _date DESC LIMIT $comd, ".$cfg['plugin']['recentcomments']['commentsperpage']);

2.Сразу после данной строки с SQL запросом добавим опеределине массива, содержащего кол-во комментариев к каждому объекту:

$com_count = array();

3. Внесем в цикл

	while($row = $sqlcom->fetch())
	{
		$com_latest[] = $row['_id'];
	}

строку

$com_count[$row['com_code']] = $row['_count'];

и получим:

	while($row = $sqlcom->fetch())
	{
		$com_latest[] = $row['_id'];
		$com_count[$row['com_code']] = $row['_count'];
	}

4. Добавим в определение тегов после 102 строки новый тег:

"RECENTCOMMENTS_ROW_COUNT" => $com_count[$k]

Готово.

Twiebie
#12 2012-11-08 12:55

Please use English in the normal sections of the forums.