count_news_comments error [solved]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
baselve

count_news_comments error [solved]

Post 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;
Last edited by baselve on Mon Jan 08, 2007 7:16 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: count_news_comments error

Post 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'}
Last edited by Anonymous on Mon Jan 08, 2007 5:58 pm, edited 1 time in total.
baselve

Re: count_news_comments error

Post 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???
Last edited by baselve on Mon Jan 08, 2007 5:34 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: count_news_comments error

Post 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  >:( ...
Last edited by Anonymous on Mon Jan 08, 2007 6:05 pm, edited 1 time in total.
baselve

Re: count_news_comments error [solved]

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

Re: count_news_comments error [solved]

Post by Dr.CSS »

Glad it worked out for you, I'm not a developer either, just kinda know how this system works... ;)
jcpg
New Member
New Member
Posts: 2
Joined: Thu Jan 03, 2008 2:19 pm

Re: count_news_comments error [solved]

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

Re: count_news_comments error [solved]

Post 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....
Locked

Return to “Modules/Add-Ons”