comments data stored?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

comments data stored?

Post by Dr.CSS »

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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: comments data stored?

Post by calguy1000 »

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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: comments data stored?

Post by Elijah Lofgren »

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?
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)

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;
Here's how I call it from the News Summary Template:

Code: Select all

Number of comments: {count_news_comments thenewsid=$entry->id}
For a regular page something like this should work:

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. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: comments data stored?

Post by Ted »

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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: comments data stored?

Post by Elijah Lofgren »

maksbud wrote: i still don't get it am i suposed to change this to something,,,

$params['thenewsid']
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: 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
Try something like this on the page that you're wanting to show the number of comments on:
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. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

;D ;D ;D yes it worked!!!

Comments [{KommentCount thenewsid=65}]

YES YES 

now it works as a blog right?

    THANK YOU so much
                                  mark
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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
Last edited by Dr.CSS on Tue May 09, 2006 3:44 pm, edited 1 time in total.
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: comments data stored?

Post by Elijah Lofgren »

maksbud wrote: now i get,,
--Add Me - module:Blog string:Comments-- [DB error: Unknown column 'module_name' in 'where clause'
Either you're not running the SVN version of the Comments module or you need to change:
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'";
to:
// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments 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='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. :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: comments data stored?

Post by Dr.CSS »

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  ;)
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: comments data stored?

Post by Elijah Lofgren »

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-- ,
Weird. When I got an error like that it meant I needed to add a lang string to the language file for my module.
Try adding this to modules/Blog/lang/en_US.php and see if that error goes away:

Code: Select all

$lang['Comments'] = 'Comments';
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.
I think this may mean you need to use the SVN version of CMSMS (or 0.13 beta 3 if it comes out today).
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. :)
Post Reply

Return to “Modules/Add-Ons”