Dla zainteresowanych - w 2 dni zmodyfikowalem relateditems i swietnie spelnia moje oczekiwania (zmienilem nazwe modulu na mod_itemsfromcat)
KOD:
helper.php
Kod:
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
class modItemsFromCatHelper
{
function getList($params)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$temp = JRequest::getString('id');
$temp = explode(':', $temp);
$id = $temp[0];
$showDate = $params->get('showDate', 0);
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
$related = array();
if ($option == 'com_content' && $view == 'article' && $id)
{
// sprawdzenie kategorii obecnego artykulu
$query = 'SELECT catid' .
' FROM #__content' .
' WHERE id = '.(int) $id;
$db->setQuery($query);
//Returns the first field of the first row returned from the most recent database query or false if the query failed.
if ($categid = trim($db->loadResult()))
{
// select other items based on the metakey field 'like' the keys found
$query = 'SELECT a.id, a.title, DATE_FORMAT(a.created, "%Y-%m-%d") AS created, a.sectionid, a.catid, cc.access AS cat_access, s.access AS sec_access, cc.published AS cat_state, s.published AS sec_state,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
' FROM #__content AS a' .
' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' .
' LEFT JOIN #__categories AS cc ON cc.id = a.catid' .
' LEFT JOIN #__sections AS s ON s.id = a.sectionid' .
' WHERE a.catid = '.(int) $categid.
' AND a.state = 1' .
' AND a.access <= ' .(int) $user->get('aid', 0) .
//' AND ( a.metakey LIKE "%'.implode('%" OR a.metakey LIKE "%', $likes).'%" )' .
' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )' .
' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'.
' ORDER BY a.ordering';
$db->setQuery($query);
$temp = $db->loadObjectList();
if (count($temp))
{
foreach ($temp as $row)
{
if (($row->cat_state == 1 || $row->cat_state == '') && ($row->sec_state == 1 || $row->sec_state == '') && ($row->cat_access <= $user->get('aid', 0) || $row->cat_access == '') && ($row->sec_access <= $user->get('aid', 0) || $row->sec_access == ''))
{
$row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
$related[] = $row;
}
}
}
unset ($temp);
}
}
return $related;
}
}
mod_itemsfromcat.php
Kod:
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
// Include the syndicate functions only once
require_once (dirname(__FILE__).DS.'helper.php');
$list = modItemsFromCatHelper::getList($params);
if (!count($list)) {
return;
}
$showDate = $params->get('showDate', 0);
require(JModuleHelper::getLayoutPath('mod_itemsfromcat'));
oczywiscie jeszcze trzeba sobie zrobic mod_itemsfromcat.xml oraz
katalog tmpl w ktorym bedzie plik
default.php - to mozna skopiowac z relateditems.
Pozdrowienia !
m-mike