Giorgi625 VIP
Total posts: 655
13 Mar 2018 20:07

Click here to link... here on last right collumn there is info about last comment.

I am working on custom forum template. Forum tempalte from package has difficult structure for me so I used cobalt7 template for category index and edited it. It is almost ready but as this template by default is not dedicated for forum it does not have block for display last comments so I opened forum template and added this two codes to my template: This one to place where I want to display that info.

<?php if($cat->comments_num):?>
    <?php echo lastCatComemnt($cat->id, $obj->section);?>
<?php else:?>

and this one at the end of file


<?php function lastCatComemnt($id, $section) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('c.user_id, c.ctime, c.record_id'); $query->from('#__js_res_comments AS c'); $query->select('r.title'); $query->leftJoin('#__js_res_record AS r ON r.id = c.record_id'); $query->where('c.published = 1'); $query->order('c.ctime DESC'); $query->where('c.record_id IN(SELECT record_id FROM #__js_res_record_category WHERE catid = '.$id.')'); $db->setQuery($query, 0, 1); $row = $db->loadObject(); $patern = '<div><a href="/%s">%s</a></div><small>%s On %s</small>'; return sprintf($patern, JRoute::_(Url::record($row->record_id, $section)), $row->title, CCommunityHelper::getName($row->user_id, $section), JHtml::_('date', $row->ctime, 'd M Y')); }

I just copied this codes from forum template, but I am jsut missing something, because I can only display username(not linkable) and date. There is not title for record which has last comment. Click here to link... check second subcategory with light bulb icon. on right there is my name and date only.

Can someone tell me what I am missing?

Last Modified: 09 Apr 2018


Giorgi625 VIP
Total posts: 655
06 Apr 2018 08:19

So code above displays only author of latest comment and date, but how to display link to this comment before author? Like it is on this forum?

Is there a universal url which redirects to latest comment?


Giorgi625 VIP
Total posts: 655
06 Apr 2018 08:31

Another question. In forum pack on category index if there is new record but it does not have comment we see -- this.

But here Even if new record does not have comment we see its title and date. How to do that?


Sergey
Total posts: 13,748
09 Apr 2018 09:16

The link is a simple link to article. The same as title. You may add to this link anchor #comment12 where 12 is an ID of the comment. I have this anchor in every template of comments. If not you can add this as well.

Powered by Cobalt