Появилась у меня минутка времени, и в рамках тестирования JComments под Joomla 1.6 решил интегрировать его с SOBI2 Pro.
1. Открываем файл /components/com_sobipro/usr/templates/default/entry/details.xsl
2. В самом конце файла перед строчкой:
<div style="clear:both;"></div>
добавляем
<xsl:variable name="EntryId">
<xsl:value-of select="entry/@id" />
</xsl:variable>
<xsl:variable name="EntryName">
<xsl:value-of select="entry/name" />
</xsl:variable>
<xsl:value-of select="php:function( 'TplFunctions::JComments' , $EntryId, $EntryName )" disable-output-escaping="yes" />
3. Открываем файл /components/com_sobipro/usr/templates/default/template.php
4. Находим код:
public static function Cfg( $key, $def = null, $section = 'general' )
{
return Sobi::Cfg( $key, $def, $section );
}
и добавляем:
public static function JComments( $id, $title )
{
$result = '';
$comments = JPATH_SITE.'/components/com_jcomments/jcomments.php';
if (is_file($comments)) {
require_once($comments);
$result = JComments::show($id, 'com_sobipro', $title);
}
return $result;
}
5. Создаем файл /components/com_jcomments/plugins/com_sobipro.plugin.php следующего содержания:
<?php
class jc_com_sobipro extends JCommentsPlugin
{
function getObjectTitle($id)
{
$db = & JCommentsFactory::getDBO();
$query = "SELECT o.id, o.name, o.owner, o.parent, fd.baseData"
. " FROM #__sobipro_object as o"
. " LEFT JOIN #__sobipro_field_data AS fd ON o.id = fd.sid"
. " JOIN #__sobipro_field AS f ON fd.fid = f.fid AND f.nid = 'field_name'"
. " WHERE o.id = " . $id
. " AND o.oType = 'entry'"
;
$db->setQuery($query);
$row = $db->loadObject();
$name = '';
if (!empty($row)) {
$name = empty($row->name)? (isset($row->baseData)? $row->baseData : '') : $row->name;
}
return $name;
}
function getObjectLink($id)
{
$db = & JFactory::getDBO();
$query = "SELECT o.id, o.parent"
. " FROM #__sobipro_object as o"
. " WHERE o.id = " . $id
. " AND o.oType = 'entry'"
;
$db->setQuery($query);
$row = $db->loadObject();
$link = '';
if (!empty($row)) {
if (!defined( 'SOBIPRO')) {
$ver = new JVersion();
$ver = str_replace( '.', null, $ver->RELEASE );
define( 'SOBI_CMS', 'joomla'. $ver );
define( 'SOBIPRO', true );
define( 'SOBI_TASK', 'task' );
define( 'SOBI_DEFLANG', JFactory::getLanguage()->getDefault() );
define( 'SOBI_ACL', 'front' );
define( 'SOBI_ROOT', JPATH_ROOT );
define( 'SOBI_MEDIA', implode( DS, array( JPATH_ROOT, 'media', 'sobipro' ) ) );
define( 'SOBI_MEDIA_LIVE', JURI::root().'/media/sobipro' );
define( 'SOBI_PATH', SOBI_ROOT.DS.'components'.DS.'com_sobipro' );
define( 'SOBI_LIVE_PATH', 'components/com_sobipro' );
require_once ( SOBI_PATH.DS.'lib'.DS.'base'.DS.'fs'.DS.'loader.php' );
}
SPLoader::loadClass('cms.base.lang');
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.request');
SPLoader::loadClass('base.object');
SPLoader::loadClass('sobi');
$link = Sobi::Url(array('title' => $row->name, 'pid' => $row->parent, 'sid' => $row->id));
}
return $link;
}
}
?>
Все, после этого можно будет комментировать.