In LDU recent items had the function to get the latest comments from pages polls and other areas. In seditio this feature for some reason removed we are going to bring it up in seditio.
Special thanks to Orkan who managed to improve the function from ldu to get the latest comments grouped by location
Open plugins\recentitems\recentitems.php
In the /* ============ MASKS FOR THE HTML OUTPUTS =========== */
add these lines
$cfg['plu_mask_comments'] = "%1$s"." ".$cfg['separator']." "."%2$s"." (%3$s)<br />"; // %1$s = Link to the comment // %2$s = Author // %3$s = Date
You can of course change the html output to what you want.
Then add this function to the file.
function sed_get_latestcomments($limit, $mask) { global $L, $db_com, $usr, $cfg, $plu_empty; $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); switch($j) { case 'p': $lnk = "<a href=\"page.php?id=$k&comments=1#c".$row['com_id']."\">".$L['Page']." #".$k."</a>"; break; case 'v': $lnk = "<a href=\"javascript:polls('".$k."&comments=1#c".$row['com_id']."')\">".$L['Poll']." #".$k."</a>"; break; case 'f': $lnk = "<a href=\"plug.php?e=faq&q=$k&comments=1#c".$row['com_id']."\">Faq #".$k."</a>"; break; case 'e': $lnk = "<a href=\"plug.php?e=events&m=details&id=$k&comments=1#c".$row['com_id']."\">Event #".$k."</a>"; break; default: $lnk = ''; break; } if(!empty($lnk)){ $res .= sprintf($mask, $lnk, sed_cc($row['com_author']), date($cfg['formatmonthday'], $row['com_date'] + $usr['timezone'] * 3600)); } } $res = (empty($res)) ? $plu_empty : $res; return($res); }
It doesn’t matter where you will place it but to keep order of things place it under all the rest functions.
Find this code
if (!$cfg['disable_polls']) { $latestpoll = sed_get_latestpolls(); }
Under it add this part of code
if (!$latestcomments && $cfg['plugin']['recentitems']['maxcomments']>0) { $latestcomments = sed_get_latestcomments($cfg['plugin']['recentitems']['maxcomments'], $cfg['plu_mask_comments'] ); sed_cache_store('latestcomments', $latestcomments, 120); }
Find this line
"PLUGIN_LATESTPAGES" => $latestpages,
Above it add this line
"PLUGIN_LATESTCOMMENTS" => $latestcomments,
We are finished with the main code, now we have to add the config entry in our setup file.
Open plugins\recentitems\recentitems.setup.php
Find this line
maxpages=01:select:0,1,2,3,4,5,6,7,8,9,10,15,20,25,30:5:Recent pages displayed
Under this add this line
maxcomments=02:select:0,1,2,3,4,5,6,7,8,9,10,15,20,25,30:10:Recent comments displayed
Now reinstall the plugin, edit the new config as you like and use this tag {PLUGIN_LATESTCOMMENTS} in index to get the latest comments.
Feed for this Entry Trackback Address The permalink
6 Responses to “Latest Comments in Sed”
May 31st, 2006 at 8:41 am
That function can be improved even more by replacing eg. “Page #23″ thing, to something more decriptive… but this will require one extra sql_query() in each loop.
Cheers ![]()
February 25th, 2007 at 6:06 pm
I cant get this to work with sed 110..
Did as described.. Any ideas?
April 22nd, 2008 at 12:41 pm
Hey,
I did evrything above twice,
But the latest comments is showing / ( at the index?
Is it because i am using the newer sed version?
Greetz,


Recent Comments