comments data stored?
comments data stored?
where is the data stored for the comments on a page?
if i add a comment to a page is there any way to connect to the data that stores the comments on that page and count the number of comments and ehco it to another page as a number such as Comments [ 12 ] ?
would this be a PHP or Tag?
mark
if i add a comment to a page is there any way to connect to the data that stores the comments on that page and count the number of comments and ehco it to another page as a number such as Comments [ 12 ] ?
would this be a PHP or Tag?
mark
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: comments data stored?
The comments themselves are stored in a table..... so yes, you could write a tag or a plugin for extracting the number of comments for a page, but I don't know if the new comments module exports this data to smarty automatically for you.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: comments data stored?
i obviously need to learn PHP,, any quick tips to that, and learn another language if i'm going to jump on other lang. forums here, saw one in french about a new design and ported it to CMSMS but can't help her without translater.
mark
mark
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
- Location: Deatsville, AL
Re: comments data stored?
I just wrote a user defined tag that counts the number of comments on a news entry (new feature in CMSMS SVN and Comments SVN)maksbud wrote: where is the data stored for the comments on a page?
if i add a comment to a page is there any way to connect to the data that stores the comments on that page and count the number of comments and ehco it to another page as a number such as Comments [ 12 ] ?
would this be a PHP or Tag?
Here's the code for it:
Code: Select all
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE page_id =".$params['thenewsid']." AND module_name='News' AND active='1'";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
Code: Select all
Number of comments: {count_news_comments thenewsid=$entry->id}
Code: Select all
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE page_id =".$params['thenewsid'];
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 

Re: comments data stored?
cool 
and i put this main code in a PHP, and that goes where?
do i change the,
page_id =".$params['thenewsid']." AND module_name='News' AND active='1'";
to comments?
was hoping to put it at the bottom of a content like Comments [ 4 ] and you would clik on the word Comments and it would take you to a page where you could read/write comments.
mark

and i put this main code in a PHP, and that goes where?
do i change the,
page_id =".$params['thenewsid']." AND module_name='News' AND active='1'";
to comments?
was hoping to put it at the bottom of a content like Comments [ 4 ] and you would clik on the word Comments and it would take you to a page where you could read/write comments.
mark
Re: comments data stored?
The way that I got it working last night was having the comments module embedded into the detail view. At the bottom of the detail template, you put in the {cms_module module='comments' modulename='News' pageid=$entry->id} and it would show the list for that article. His plugin is just a little extension so that you can see the number on the summary tempate as well.
Re: comments data stored?
i still don't get it am i suposed to change this to something,,,
$params['thenewsid']
is that param the 'content_id='65'', this is what i get when i edit the page,,
editcontent.php?content_id=65&page=1
i've put this in the 'content edit box' {cms_module module="komments"} and it shows up like a normal comments with "add a comment" and the comments made,
i changed it to 'komments' because i messed with the original and had to add a new Module by changing everything in the PHP including the Folder name, i really like the "mess" i made to the original template and can't add another template hence the 'new' Module,,
and how would i make it show up in these [ ] as a number,
i've got a redirect to the page, bottom of content has Comments [ ] link to page that doesn't show in menu,, i just need to count the items on that page and echo it into those brackets Comments [ 4 ]
thanks for any help
mark
$params['thenewsid']
is that param the 'content_id='65'', this is what i get when i edit the page,,
editcontent.php?content_id=65&page=1
i've put this in the 'content edit box' {cms_module module="komments"} and it shows up like a normal comments with "add a comment" and the comments made,
i changed it to 'komments' because i messed with the original and had to add a new Module by changing everything in the PHP including the Folder name, i really like the "mess" i made to the original template and can't add another template hence the 'new' Module,,
and how would i make it show up in these [ ] as a number,
i've got a redirect to the page, bottom of content has Comments [ ] link to page that doesn't show in menu,, i just need to count the items on that page and echo it into those brackets Comments [ 4 ]
thanks for any help

mark
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
- Location: Deatsville, AL
Re: comments data stored?
That actually holds the page id (or in my case the news id). You could change the name but you don't need to.maksbud wrote: i still don't get it am i suposed to change this to something,,,
$params['thenewsid']
Try something like this on the page that you're wanting to show the number of comments on:maksbud wrote: is that param the 'content_id='65'', this is what i get when i edit the page,,
editcontent.php?content_id=65&page=1
i've put this in the 'content edit box' {cms_module module="komments"} and it shows up like a normal comments with "add a comment" and the comments made,
i changed it to 'komments' because i messed with the original and had to add a new Module by changing everything in the PHP including the Folder name, i really like the "mess" i made to the original template and can't add another template hence the 'new' Module,,
and how would i make it show up in these [ ] as a number,
i've got a redirect to the page, bottom of content has Comments [ ] link to page that doesn't show in menu,, i just need to count the items on that page and echo it into those brackets Comments [ 4 ]
thanks for any help
mark
Note (The thenewsid parameter is actually the id of the page with the comments on it. So if the id of the page with the comments on it is 65, pass 65 as the parameter).
Code: Select all
Comments: [ {count_news_comments thenewsid=65} ]
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 

Re: comments data stored?
i've tried to make a tag out of that code and get this no matter if i put it in the edit page content or template, must be messing something up,,
Comments [{nocache:1fd63301dd53ba98789f3d4cbcf48072#0}DB error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Fatal error: Call to a member function on a non-object in /homepages/24/d151200904/htdocs/lib/content.functions.php(649) : eval()'d code on line 12
and a bunch of nocache errors all over the page other wise page shows up normal, put this in the template,,
Comments [{KommentCount}]
should i put {lieral} arond it?
mark
Comments [{nocache:1fd63301dd53ba98789f3d4cbcf48072#0}DB error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Fatal error: Call to a member function on a non-object in /homepages/24/d151200904/htdocs/lib/content.functions.php(649) : eval()'d code on line 12
and a bunch of nocache errors all over the page other wise page shows up normal, put this in the template,,
Comments [{KommentCount}]
should i put {lieral} arond it?
mark
Re: comments data stored?



Comments [{KommentCount thenewsid=65}]
YES YES
now it works as a blog right?
THANK YOU so much
mark
Re: comments data stored?
ok so what i need now is a way to make a new page on the fly when you clik the Comments link ,,
you clik the link and it makes its own page with out having to have a page made aready like the "Add New Content" at the bottom of the "Content » Pages" in admin, and have a way to set the Default Template so it just gives them a page to add comments to,,
well you know what i mean
right?
i've got it set up to use the news module with a detail page template as summary and it shows all the news detail not summary, in newest to oldest order, but the Comments [ 4 ] links to the same page for each 'news' article, don't want to add new Comments page for each 'article' by hand hoping there is some way to make them on the fly,, not too much to ask is it?
thanks
mark
you clik the link and it makes its own page with out having to have a page made aready like the "Add New Content" at the bottom of the "Content » Pages" in admin, and have a way to set the Default Template so it just gives them a page to add comments to,,
well you know what i mean

i've got it set up to use the news module with a detail page template as summary and it shows all the news detail not summary, in newest to oldest order, but the Comments [ 4 ] links to the same page for each 'news' article, don't want to add new Comments page for each 'article' by hand hoping there is some way to make them on the fly,, not too much to ask is it?

thanks
mark
Re: comments data stored?
now i get,,
--Add Me - module:Blog string:Comments-- [DB error: Unknown column 'module_name' in 'where clause'
Fatal error: Call to a member function on a non-object in /homepages/24/d151200904/htdocs/lib/content.functions.php(649) : eval()'d code on line 12
i took news and made it blog everything else works cept when i put the 'count' in, i made two U D Tags, one has,,
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_komments WHERE page_id =".$params['theid'];
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
this first one works when i make the page and have [ {count theid=65} ] not the other one [ {blogcount theid=$entry->id} ],,
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_komments WHERE page_id =".$params['theid']." AND module_name='Blog' AND active='1'";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
ohwell
mark
--Add Me - module:Blog string:Comments-- [DB error: Unknown column 'module_name' in 'where clause'
Fatal error: Call to a member function on a non-object in /homepages/24/d151200904/htdocs/lib/content.functions.php(649) : eval()'d code on line 12
i took news and made it blog everything else works cept when i put the 'count' in, i made two U D Tags, one has,,
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_komments WHERE page_id =".$params['theid'];
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
this first one works when i make the page and have [ {count theid=65} ] not the other one [ {blogcount theid=$entry->id} ],,
global $gCms;
$db = &$gCms->db;
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_komments WHERE page_id =".$params['theid']." AND module_name='Blog' AND active='1'";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;
ohwell
mark
Last edited by Dr.CSS on Tue May 09, 2006 3:44 pm, edited 1 time in total.
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
- Location: Deatsville, AL
Re: comments data stored?
Either you're not running the SVN version of the Comments module or you need to change:maksbud wrote: now i get,,
--Add Me - module:Blog string:Comments-- [DB error: Unknown column 'module_name' in 'where clause'
to:maksbud wrote: // Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_komments WHERE page_id =".$params['theid']." AND module_name='Blog' AND active='1'";
And unless you really changed the name of the News module you'll want to use this instead:// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE page_id =".$params['theid']." AND module_name='Blog' AND active='1'";
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE page_id =".$params['theid']." AND module_name='News' AND active='1'";
Last edited by Anonymous on Tue May 09, 2006 4:09 pm, edited 1 time in total.
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 

Re: comments data stored?
made new modules, Blog, out of News,,
Komments, out of Comments, modified the original one of these as explained in earlier post,
now i get,,
--Add Me - module:Blog string:Comments-- 0 it counts now, i've looked thru all the 'Blog' PHP and i can't find anywhere else to --Add Me-- , but i can clik Comments and get taken to another page where it says add comment, but when i clik 'Add a Comment' it returns me to the original page, unable to add comment, still messing with the templates, about time i learn PHP.
mark
Komments, out of Comments, modified the original one of these as explained in earlier post,
now i get,,
--Add Me - module:Blog string:Comments-- 0 it counts now, i've looked thru all the 'Blog' PHP and i can't find anywhere else to --Add Me-- , but i can clik Comments and get taken to another page where it says add comment, but when i clik 'Add a Comment' it returns me to the original page, unable to add comment, still messing with the templates, about time i learn PHP.
mark

- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
- Location: Deatsville, AL
Re: comments data stored?
Weird. When I got an error like that it meant I needed to add a lang string to the language file for my module.maksbud wrote: --Add Me - module:Blog string:Comments-- 0
it counts now, i've looked thru all the 'Blog' PHP and i can't find anywhere else to --Add Me-- ,
Try adding this to modules/Blog/lang/en_US.php and see if that error goes away:
Code: Select all
$lang['Comments'] = 'Comments';
I think this may mean you need to use the SVN version of CMSMS (or 0.13 beta 3 if it comes out today).maksbud wrote: but i can clik Comments and get taken to another page where it says add comment, but when i clik 'Add a Comment' it returns me to the original page, unable to add comment, still messing with the templates, about time i learn PHP.
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 
