Joomla generalnie ma coś z tym sortowaniem, no...
Znalazłem rozwiązanie , ale zadziałało tylko w backendzie.
Ponadawałem artykułom właściwa kolejność, ale na stronie startowej dalej wyświetlały się w kolejności id.
Wpadłem na pomysł jak to rozwiązać:
w pliku components/com_content/content.php
trzeba znaleźć
function frontpage( $gid, &$access, $pop, $now, $limit, $limitstart ) {
global $database, $mainframe;
$now = _CURRENT_SERVER_TIME;
$nullDate = $database->getNullDate();
$noauth = !$mainframe->getCfg( 'shownoauth' );
// Parameters
$menu = $mainframe->get( 'menu' );
$params = new mosParameters( $menu->params );
// Ordering control
$orderby_sec = $params->def( 'orderby_sec', '' );
$orderby_pri = $params->def( 'orderby_pri', '' );
$order_sec = _orderby_sec( $orderby_sec );
$order_pri = _orderby_pri( $orderby_pri );
// voting control
$voting = $params->def( 'rating', '' );
$voting = votingQuery($voting);
$where = _where( 1, $access, $noauth, $gid, 0, $now, NULL, NULL, $params );
$where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
// Limit & limitstart
$intro = $params->def( 'intro', 4 );
$leading = $params->def( 'leading', 1 );
$links = $params->def( 'link', 4 );
$limit = $intro + $leading + $links;
// query to determine total number of records
$query = "SELECT COUNT(a.id)"
. "\n FROM #__content AS a"
. "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
. "\n INNER JOIN #__sections AS s ON s.id = a.sectionid"
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
. "\n LEFT JOIN #__groups AS g ON a.access = g.id"
. $where
;
$database->setQuery( $query );
$total = $database->loadResult();
if ( $total <= $limit ) {
$limitstart = 0;
}
// query records
$query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
. "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access, a.hits,"
. "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.username AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
. "\n, s.id AS sec_id, cc.id as cat_id"
. $voting['select']
. "\n FROM #__content AS a"
. "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
. "\n INNER JOIN #__sections AS s ON s.id = a.sectionid"
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
. "\n LEFT JOIN #__groups AS g ON a.access = g.id"
. $voting['join']
. $where
. "\n ORDER BY $order_pri $order_sec"
i ostatnią linię zamienić na
function frontpage( $gid, &$access, $pop, $now, $limit, $limitstart ) {
global $database, $mainframe;
$now = _CURRENT_SERVER_TIME;
$nullDate = $database->getNullDate();
$noauth = !$mainframe->getCfg( 'shownoauth' );
// Parameters
$menu = $mainframe->get( 'menu' );
$params = new mosParameters( $menu->params );
// Ordering control
$orderby_sec = $params->def( 'orderby_sec', '' );
$orderby_pri = $params->def( 'orderby_pri', '' );
$order_sec = _orderby_sec( $orderby_sec );
$order_pri = _orderby_pri( $orderby_pri );
// voting control
$voting = $params->def( 'rating', '' );
$voting = votingQuery($voting);
$where = _where( 1, $access, $noauth, $gid, 0, $now, NULL, NULL, $params );
$where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
// Limit & limitstart
$intro = $params->def( 'intro', 4 );
$leading = $params->def( 'leading', 1 );
$links = $params->def( 'link', 4 );
$limit = $intro + $leading + $links;
// query to determine total number of records
$query = "SELECT COUNT(a.id)"
. "\n FROM #__content AS a"
. "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
. "\n INNER JOIN #__sections AS s ON s.id = a.sectionid"
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
. "\n LEFT JOIN #__groups AS g ON a.access = g.id"
. $where
;
$database->setQuery( $query );
$total = $database->loadResult();
if ( $total <= $limit ) {
$limitstart = 0;
}
// query records
$query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
. "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access, a.hits,"
. "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.username AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
. "\n, s.id AS sec_id, cc.id as cat_id"
. $voting['select']
. "\n FROM #__content AS a"
. "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
. "\n INNER JOIN #__sections AS s ON s.id = a.sectionid"
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
. "\n LEFT JOIN #__groups AS g ON a.access = g.id"
. $voting['join']
. $where
. "\n ORDER BY a.created DESC"
To załatwiło problem!
