Page 1 of 1

count_news_comments error [solved]

Posted: Mon Jan 08, 2007 4:08 pm
by baselve
I'm trying to extend the news module for use as a blog. I've followed the wiki etc etc. but there 's a problem with the user defined tag: count_news_comments. I made the tag succesfully and edited the news templates as written in the wiki. When I test the blog I get this error (translated out of Dutch):

DB error: There's something wrong with the used syntax  'AND module_name='News' AND active='1'' on line 3

Fatal error: Call to a member function on a non-object in c:\program files\easyphp1-8\www\blog\lib\content.functions.php(663) : eval()'d code on line 14

I'm running: CMS Made Simple 1.0.2 "Maui", Apache/1.3.33 (Win32) PHP/4.3.10, MySQL 4.1.9

My user defined tag count_news_comments looks like this:

name: count_news_comments

code:
global $gCms;

$db = &$gCms->db;

// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments
WHERE  page_id =".$params['theid']."
AND module_name='News' AND active='1'";
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();
echo $num_rows;

Re: count_news_comments error

Posted: Mon Jan 08, 2007 4:46 pm
by Dr.CSS
"user defined tag: count_news_comments." there is no tag for that the only one I found was for "count_news_items".

To get the count of comments use this UDT...

global $gCms;

$db = &$gCms->db;

// Get number of comments
$q = "SELECT * FROM ".cms_db_prefix()."module_comments WHERE  page_id =".$params['theid'];
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
    echo 'DB error: '. $db->ErrorMsg()."";
}
$num_rows = $dbresult->RecordCount();  In older ver. of CMSMS this would be RowCount...
echo $num_rows;

I use it in the summary template like so...


{$entry->morelink}  [ {count theid=$entry->id} ]


To get Comments in News you add this at the end of the Detail template just before after the last {/if}, of course you need the comments module installed for all this to work...

{cms_module module='comments' modulename='News' pageid=$entry->id emailfield='1' websitefield='1'}

Re: count_news_comments error

Posted: Mon Jan 08, 2007 5:13 pm
by baselve
Thank you, but the wiki/handbook I mean is: http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel/Content/Comments#Show_count_of_comments_in_news_summary

Thank you it works now, but is the wiki above wrong at this point???

Re: count_news_comments error

Posted: Mon Jan 08, 2007 5:59 pm
by Dr.CSS
See it in action...

http://www.multiintech.com/Templates/in ... /Home.html

EDIT: I don't know, Elijah and I worked this one out back in CMSMS Ver. 0.13...

NOTE: in the above post the tag needs to go AFTER the last {/if}....

ps. if this is [solved] please add it to the end of the subject line in your first post.. thanks...
I do it some times but I don't want people to get  >:( ...

Re: count_news_comments error [solved]

Posted: Mon Jan 08, 2007 7:20 pm
by baselve
Thank you so(!!!) much!

It works fine now, with your comments counter and the blog template from the wiki. In a few weeks I hope to build a complete blog, with categories, search, commments etc. Only the permalinks wil hard to make (not much information to find). I hope I can show you my blog soon, and maybe I have to call in your help once more because I'm more a designer than a dev'er. Thanks again!

Re: count_news_comments error [solved]

Posted: Mon Jan 08, 2007 9:27 pm
by Dr.CSS
Glad it worked out for you, I'm not a developer either, just kinda know how this system works... ;)

Re: count_news_comments error [solved]

Posted: Tue Sep 16, 2008 7:22 pm
by jcpg
Hello:
I have The same problem happen to me when I try to create a user tag, but It's keep giving me the forbbiden error... How do you solved it?..
Thanks in advanced.

JCPG

Re: count_news_comments error [solved]

Posted: Thu Oct 02, 2008 8:57 pm
by Dr.CSS
You will have to give more info to get help on this...

What were you trying to create, how/when did the error show etc....