-
AuthorPosts
-
hcharly Friend
hcharly
- Join date:
- April 2008
- Posts:
- 107
- Downloads:
- 0
- Uploads:
- 9
- Thanks:
- 14
- Thanked:
- 11 times in 1 posts
September 19, 2011 at 7:04 pm #168734Hello All,
I’m integrating JA Comment to the Mighty Resources Component.
Does somebody knows what is the standard code to get Comments Count in a blog list?
Thanks.
-Charleshcharly Friendhcharly
- Join date:
- April 2008
- Posts:
- 107
- Downloads:
- 0
- Uploads:
- 9
- Thanks:
- 14
- Thanked:
- 11 times in 1 posts
September 22, 2011 at 6:58 pm #414348Hello All,
<em>@hcharly 268952 wrote:</em><blockquote>Hello All,
I’m integrating JA Comment to the Mighty Resources Component.
Does somebody knows what is the standard code to get Comments Count in a blog list?
Thanks.
-Charles</blockquote>I’m done. It’s working great!
Here is how to integrate JA Comment to Mighty Resources CCK.1) In the files
administrator / components / com_resource / xml / config_g.xml
administrator / components / com_resource / xml / config.xml
I added a new option to the “comments” parameter to support JA Comment OOTB
– config_g.xml line 1110
– config.xml line 1076
<option value="4"> JAComments </option>
This make it possible to select “JAComments” as a commenting system for MightyResources contents.
2) Added some codes to the file components / com_resource / views / article / tmpl / default.php
This codes enable the use of JA Comments for the specific Type for which it is selected.
Find [php] echo $this-> LoadTemplate (‘comments’);[/php] near line 29
and replace it by the following:
[php]
if($this->params->get(‘comments’) == 4 && file_exists(JPATH_BASE.DS. “/plugins/content/jacomment.php”)) {
include_once(JPATH_BASE.DS. “/plugins/content/jacomment.php”);
echo “{jacomment contentid=”.$this->article->id.” option=com_resource contenttitle=”.$this->article->title.”}”;
} else {
echo $this->loadTemplate(‘comments’);
}
[/php]
This means that user can now use JAComment for some Resources’ contents while continuing
to use the standard commenting component of MightyRes for other types.
According to the code, the comment system which comes with MRes will be used if JA Comment is not installed and Selected.3) The last problem is to get the count of the number of comments to display on the Content lists and in Articles Views.
To do that we need to edit the file components / com_resource / models / list.php.
From line 2148 in function “countComments” just before
[php] $db = & JFactory:: getDBO ();[/php]
I put the following code to intercept the database querying:
[php]
if($params->get(‘comments’) == 4)
{
$comments = JPATH_SITE.DS.’components’.DS.’com_jacomment’.DS.’models’.DS.’comments.php’;
if(file_exists($comments))
{
require_once ($comments);
$jac_model = & JModel::getInstance(‘comments’,’JACommentModel’);
$ja_query .= ‘ AND c.option=”com_resource”‘;
$ja_query .= ‘ AND c.contentid=’.$item->id.”;
$ja_query .= ‘ AND type=1’; //get only approved Items
$count = $jac_model->getTotalByType($ja_query);
if($count){
$count = (int)array_sum($count);
}else{
$count = 0;
}
return $count;
}
}
[/php]
Without touching article.php in the same directory the count is correct for Article View also!
This was enough to get the count of comments as well as Articles lists as on the Views. This works also for related content3.
You won’t need to edit your previous “resources’ templates’!That’s it.
-Charles
I’ve posted these info at the Mighty Resources AngelDesk. Maybe they will implement this.jneubauer Friendjneubauer
- Join date:
- August 2011
- Posts:
- 141
- Downloads:
- 0
- Uploads:
- 0
- Thanks:
- 4
- Thanked:
- 23 times in 23 posts
September 22, 2011 at 8:57 pm #414356Thanks for all the hard work on this!
And congratulations on implementing this successfully!
I’ll bring this to the attention of the development team to see if this is something they might want to integrate from Joomlart as well!
Thanks again! -
AuthorPosts
This topic contains 3 replies, has 2 voices, and was last updated by jneubauer 13 years, 3 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum