PDA

Zobacz pełną wersję : Najnowsze newsy



Artu123
27-06-2011, 09:19
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$userId = (int) $user->get('id');

$count = (int) $params->get('count', 5);
$catid = trim( $params->get('catid') );
$secid = trim( $params->get('secid') );
$show_front = $params->get('show_front', 1);
$aid = $user->get('aid', 0);

$contentConfig = &JComponentHelper::getParams( 'com_content' );
$access = !$contentConfig->get('show_noauth');

$nullDate = $db->getNullDate();

$date =& JFactory::getDate();
$now = $date->toMySQL();

$where = 'a.state = 1'
. ' 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).' )'
;

// User Filter
switch ($params->get( 'user_id' ))
{
case 'by_me':
$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
break;
case 'not_me':
$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
break;
}

// Ordering
switch ($params->get( 'ordering' ))
{
case 'm_dsc':
$ordering = 'a.modified DESC, a.created DESC';
break;
case 'c_dsc':
default:
$ordering = 'a.created DESC';
break;
}

if ($catid)
{
$ids = explode( ',', $catid );
JArrayHelper::toInteger( $ids );
$catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
}
if ($secid)
{
$ids = explode( ',', $secid );
JArrayHelper::toInteger( $ids );
$secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
}

// Content Items only
$query = 'SELECT a.*, ' .
' 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' .
($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') .
' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
' WHERE '. $where .' AND s.id > 0' .
($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
($catid ? $catCondition : '').
($secid ? $secCondition : '').
($show_front == '0' ? ' AND f.content_id IS NULL ' : '').
' AND s.published = 1' .
' AND cc.published = 1' .
' ORDER BY '. $ordering;
$db->setQuery($query, 0);
$rows = $db->loadObjectList();

foreach ( $rows as $row )
{

}

skopiowałem ten kod z modułu latest_news do szablonu, ale niestety nie działa,

tomaszek83
27-06-2011, 10:49
A co ma działać?

Artu123
27-06-2011, 11:55
$db =& JFactory::getDBO();

$query = 'SELECT MONTH( created ) AS created_month, title, introtext, created, id, sectionid, YEAR(created) AS created_year' .
' FROM #__content' .
' INNER JOIN #__content_frontpage AS f ON id = f.content_id' .
' WHERE ( state = 1 AND f.content_id > 0 )' .
' GROUP BY created DESC';
$db->setQuery($query, 0);
$rows = $db->loadObjectList();

nie wiem czemu ale nie moge pobrac fulltext, jak dodam do zapytania fulltext to w ogóle newsy sie nie wyswietlaja, a jak usune to wyswietla sie lista newsow

tomaszek83
27-06-2011, 12:01
ale dlaczego dodajesz to do templatki? co chcesz tym osiągnąć?

Artu123
27-06-2011, 12:05
po prostu potrzebne mi to jest, ale nie wiem dlaczego nie mogę pobrać fulltext

larry_krk
27-06-2011, 14:37
Bo moduł to nie szablon, a szablon to nie moduł.
Odpowiedz na pytanie Tomasza, będzie łatwiej coś poradzić. Czasem najprostsze rozwiązania są najlepsze.