0

I'm trying to add JComment capabilities to a Docman v3 site. I'm looking at the old Docman 1.4.x tutorial: http://www.joomlatune.com/jcomments-docman.html

I edited this file: /components/com_docman/views/document/tmpl/default.html.php

<?php 
//global $mosConfig_absolute_path;
$comments = 'components/com_jcomments/jcomments.php';

if (file_exists($comments))
{
    require_once($comments);
    echo '<div style="clear:both; padding-top: 10px;"></div>';
    echo JComments::show($document->id, 'com_docman', $document->title);
}
?>

I also tried modifying this file: components/com_jcomments/plugins/com_docman.plugin.php

<?php
/**
 * JComments plugin for DocMan objects support
 *
 * @version 2.0
 * @package JComments
 * @author Sergey M. Litvinov (smart@joomlatune.ru)
 * @copyright (C) 2006-2013 by Sergey M. Litvinov (http://www.joomlatune.ru)
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 */

defined('_JEXEC') or die;

class jc_com_docman extends JCommentsPlugin
{
    function getObjectTitle($id)
    {
        $db = JFactory::getDbo();
        $db->setQuery( 'SELECT title, docman_document_id FROM #__docman_documents WHERE docman_document_id = ' . $id );
        return $db->loadResult();
    }

    function getObjectLink($id)
    {
        static $_Itemid = null;

        if (!isset($_Itemid)) {
            $needles = array('gid' => (int) $id);
            if ($item = self::_findItem($needles)) {
                $_Itemid = $item->id;
            } else {
                $_Itemid = '';
            }
        }

        include_once(JPATH_SITE.'/includes/application.php');

        $link = 'index.php?option=com_docman&Itemid=408&&id=' . $id . '&lang=en-us&layout=default&view=document';

        if ($_Itemid != '') {
            $link .= '&Itemid=' . $_Itemid;
        };

        $router = JPATH_SITE.'/components/com_docman/router.php';
        if (is_file($router)) {
            include_once($router);
        }
        $link = JRoute::_($link);

        return $link;
    }

    function getObjectOwner($id)
    {
        $db = JFactory::getDbo();
        $db->setQuery( 'SELECT created_by FROM #__docman_documents WHERE docman_document_id = ' . $id );
        $userid = $db->loadResult();

        return $userid;
    }

    protected static function _findItem($needles)
    {
        $component = JComponentHelper::getComponent('com_docman');

        $menus = JApplication::getMenu('site');
        $items = $menus->getItems('componentid', $component->id);
        $user = JFactory::getUser();
        $access = (int)$user->get('aid');

        foreach ($needles as $needle => $id) {
            if (is_array($items)) {
                foreach ($items as $item) {
                    if ($item->published == 1 && $item->access <= $access) {
                        return $item;
                    }
                }
            }
        }

        return false;
    }

}

The only problem now, is the LINK part:

$link = 'index.php?option=com_docman&Itemid=408&&id=' . $id . '&lang=en-us&layout=default&view=document';

It looks like Docman links include the document alias instead of the ID, and the category slug is also included in the URL. If anyone can provide any pointers on how to bring those values into /components/jcomments/plugins/com_docman.plugin.php I would be most appreciative! It looks like the Komento plugin that comes with Docman3 might provide some clues...

  • You need to modify SQL queries in components/com_jcomments/plugins/com_docman.plugin.php to support Docman 3 database structure. – Sharky Feb 11 at 15:09
  • Thank you! I got it most of the way working except for the "LINK" that it creates for the Docman Document. It now also requires the document alias and the category slug in order to properly create the link... – c2oxide Feb 11 at 16:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.