Latest Comments List [solved]
Latest Comments List [solved]
Hello,
Sorry about my english.
Is there any function in comments module to show off latest comments in global mode (i.e. on first/main page)?
Maybe with link to this comments/articles ?
If not - maybe there is a simple way to do something like that list of new comments?
Thank You for any help.
Greetings
Marek
Sorry about my english.
Is there any function in comments module to show off latest comments in global mode (i.e. on first/main page)?
Maybe with link to this comments/articles ?
If not - maybe there is a simple way to do something like that list of new comments?
Thank You for any help.
Greetings
Marek
Last edited by ankel on Tue Feb 27, 2007 11:23 am, edited 1 time in total.
Re: Latest Comments List
Think there's no function like this.
But there exists a tag on default install named "recently updated". Shouldn't be too difficult to modify it for using with comments ...
But there exists a tag on default install named "recently updated". Shouldn't be too difficult to modify it for using with comments ...
Re: Latest Comments List
I wrote something like that, and working fine 

Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function smarty_cms_function_latest_comments($params, &$smarty)
{
if(empty($params['number']))
{
$number = 5;
}
else
{
$number = $params['number'];
}
$output = '<ul>';
global $gCms;
$hm =& $gCms->GetHierarchyManager();
$db = &$gCms->db;
// Get list of most recently updated pages excluding the home page
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE active = 1 ORDER BY modified_date DESC LIMIT ".$number;
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
$curnode =& $hm->getNodeById($updated_page['comment_id']);
$output .= '<li>';
$output .= '<a href="http://rzepin.net/news/'.$updated_page['page_id'].'">'.substr($updated_page['comment_data'], 0, 40).' (...)</a>';
$output .= ' Napisano: ' .$updated_page['modified_date'];
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
function smarty_cms_help_function_latest_comments() {
?>
<h3>What does this do?</h3>
<p>Outputs a list of latest comments.</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{latest_comments}</code></p>
<h3>What parameters does it take?</h3>
<ul>
<li><p><em>(optional)</em> number='5' - Number of updated pages to show.</p><p>Example: <pre>{recently_updated number='15'}</li>
</ul>
</p>
<?php
}
function smarty_cms_about_function_latest_comments() {
?>
<p>Author: Marek Pych basing on "recently updated" by Elijah Lofgren <elijahlofgren@elijahlofgren.com></p>
<p>Version: 1.0</p>
<p>
Change History:<br/>
None
</p>
<?php
}
?>
-
- Forum Members
- Posts: 64
- Joined: Thu Nov 08, 2007 6:18 pm
Re: Latest Comments List [solved]
I'd like to use the 'latest comments' function in my website too. (www.klassiekerrally.nl)
Where can I find how to put the right pieces of code in tags?
Somehow I can't get it to work...
Thanks for any help...
Where can I find how to put the right pieces of code in tags?
Somehow I can't get it to work...
Thanks for any help...
Re: Latest Comments List [solved]
It's quite simple.
You must create plugin file: function.latest_comments.php in /plugins/
Then paste the code of plugin in this file:
Replace from code with url of your site. Do you have pretty urls? If yes it's simple, if not - better if you active this feature.
Now put somewhere {latest_comments} in you site, and ... done.
I hope you understand me with my english
On site: http://rzepin.net latest comments working poperly.
You must create plugin file: function.latest_comments.php in /plugins/
Then paste the code of plugin in this file:
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function smarty_cms_function_latest_comments($params, &$smarty)
{
if(empty($params['number']))
{
$number = 5;
}
else
{
$number = $params['number'];
}
$output = '<ul>';
global $gCms;
$hm =& $gCms->GetHierarchyManager();
$db = &$gCms->db;
// Get list of most recently updated pages excluding the home page
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE active = 1 ORDER BY modified_date DESC LIMIT ".$number;
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
$curnode =& $hm->getNodeById($updated_page['comment_id']);
$output .= '<li>';
$output .= '<a href="http://<your_site>/news/'.$updated_page['page_id'].'">'.substr($updated_page['comment_data'], 0, 40).' (...)</a>';
$output .= ' Added: ' .$updated_page['modified_date'];
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
function smarty_cms_help_function_latest_comments() {
?>
<h3>What does this do?</h3>
<p>Outputs a list of latest comments.</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{latest_comments}</code></p>
<h3>What parameters does it take?</h3>
<ul>
<li><p><em>(optional)</em> number='5' - Number of updated pages to show.</p><p>Example: <pre>{recently_updated number='15'}</li>
</ul>
</p>
<?php
}
function smarty_cms_about_function_latest_comments() {
?>
<p>Author: Marek Pych basing on "recently updated" by Elijah Lofgren <elijahlofgren@elijahlofgren.com></p>
<p>Version: 1.0</p>
<p>
Change History:<br/>
None
</p>
<?php
}
?>
Now put somewhere {latest_comments} in you site, and ... done.
I hope you understand me with my english

On site: http://rzepin.net latest comments working poperly.

-
- Forum Members
- Posts: 64
- Joined: Thu Nov 08, 2007 6:18 pm
Re: Latest Comments List [solved]
It works! Thank you very much.
Re: Latest Comments List [solved]
@ankel : Thank you very much for the tip. Feel free to add this cool plugin in the wiki. You have write access with your forum account.
Have fun with CMSms !
Pierre M.
Have fun with CMSms !
Pierre M.
-
- Forum Members
- Posts: 36
- Joined: Sat Dec 02, 2006 7:08 pm
Re: Latest Comments List [solved]
Hi (sorry for my english, i'm french
)
This script don't work now . The list is good, with comments. but the link is bad (page doesn't exist)
you have a solution ?
thanks
(pfeuuu, mon anglais est vraiment naze
)

This script don't work now . The list is good, with comments. but the link is bad (page doesn't exist)
you have a solution ?
thanks
(pfeuuu, mon anglais est vraiment naze

Re: Latest Comments List [solved]
soupaloignon : dude, i think you did not do the pretty url thing, that's why the link is dead .
This is a great peace of code mate. thank you
I'm also using this and it works great
.
This is a great peace of code mate. thank you

I'm also using this and it works great
