PDA

Zobacz pełną wersję : Ocenianie w mXcomment + AlphaContent - potrzebna pomoc!



mjapko
09-11-2007, 11:45
Witam,
mam problem z systemem oceniania przy połączeniu systemu komentarzy mXcomment z komponentem wyświetlania zawartości AlphaContent.
A otóż, AlphaContent wyświetla na liście artykułów tylko ocenę z samego systemu oceniania Joomla, tzn. 1-5pkt., a w komponencie mXComment jest możliwość oceny artykułu przez użykowników w większej ilości punktów, np. 1-10 lub 1-20.
Jak przerobić AlphaContent tak, żeby na liście wyświetlał punktację z systemu mXComment a nie punktację Joomla?

Próbowałem już na różne sposoby, ale ponieważ nie jestem dobrze obeznany z MySQL i znam tylko podstawy PHP, więc praktycznie za każdym razem wszystko mi sie "wysypywało" (oczywiście z mojej niewiedzy).
Czy ktoś mógłby pomóc mi to poskładać?

kobylinski
09-11-2007, 13:36
Zacznij od pliku: /components/com_alphacontent/alphacontent.php
Musisz odnaleźć następujący kod i wprowadzić zmiany tak jak zaznaczyłem:


switch ( $content_typecontent ) {
case "0":
$query = "SELECT a.id AS id, a.title AS title,"
. "\n a.created AS created, a.created_by_alias,"
//. "\n CONCAT(a.introtext, a.fulltext) AS text,"
. "\n a.introtext AS text,"
. "\n a.fulltext AS fulltextmore,"
. "\n CONCAT_WS( '/', u.title, b.title ) AS section,"
. $href
. "\n '2' AS browsernav,"
. "\n a.images AS images,"
. "\n a.state AS state,"
. "\n a.hits AS hits,"
. "\n a.attribs AS attribs,"
. "\n a.created_by AS created_by,"
// To usuń . "\n ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, s.name AS author"
. "\n ROUND(AVG(mxc_c.rating)) AS rating, COUNT(mxc_c.contentid) AS rating_count, s.name AS author" // To wstaw
. "\n FROM #__content AS a"
. "\n INNER JOIN #__categories AS b ON b.id=a.catid AND b.access <= '$my->gid'"
. "\n LEFT JOIN #__sections AS u ON u.id = a.sectionid"
// To usuń . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id"
. "\n LEFT JOIN #__mxc_comments AS mxc_c ON mxc_c.contentid = a.id" // To wstaw
. "\n LEFT JOIN #__users AS s ON s.id = a.created_by"
. "\n $where"
. "\n $wheresection"
. "\n $state"
. "\n AND a.access <= '$my->gid'"
. "\n AND u.published = '1'"
. "\n AND b.published = '1'"
. "\n AND ( publish_up = '$nullDate' OR publish_up <= '$now' )"
. "\n AND ( publish_down = '$nullDate' OR publish_down >= '$now' )"
. "\n GROUP BY mxc_c.contentid" // To wstaw
. "\n ORDER BY $order"
. "\nLIMIT $pageNav->limitstart, $pageNav->limit";

$database->setQuery( $query );
$rows = $database->loadObjectList();
break;

case "2":
$query = "SELECT a.id AS id, a.title AS title,"
. "\n a.created AS created, a.created_by_alias,"
//. "\n CONCAT(a.introtext, a.fulltext) AS text,"
. "\n a.introtext AS text,"
. "\n a.fulltext AS fulltextmore,"
. $href
. "\n '2' AS browsernav,"
. "\n a.images AS images,"
. "\n a.state AS state,"
. "\n a.sectionid AS section,"
. "\n a.catid AS category,"
. "\n a.hits AS hits,"
. "\n a.attribs AS attribs,"
. "\n a.created_by AS created_by,"
// To usuń . "\n ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, s.name AS author"
. "\n ROUND(AVG(mxc_c.rating)) AS rating, COUNT(mxc_c.contentid) AS rating_count, s.name AS author" // To wstaw
. "\n FROM #__content AS a"
// To usuń . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id"
. "\n LEFT JOIN #__mxc_comments AS mxc_c ON mxc_c.contentid = a.id" // To wstaw
. "\n LEFT JOIN #__users AS s ON s.id = a.created_by"
. "\n $where"
. "\n $wheresection"
. "\n $state"
. "\n AND a.access <= '$my->gid'"
. "\n AND ( publish_up = '$nullDate' OR publish_up <= '$now' )"
. "\n AND ( publish_down = '$nullDate' OR publish_down >= '$now' )"
. "\n GROUP BY mxc_c.contentid" // To wstaw
. "\n ORDER BY $order"
. "\nLIMIT $pageNav->limitstart, $pageNav->limit";

$database->setQuery( $query );
$rows = $database->loadObjectList();
break;

case "1":
$query = "SELECT a.id AS id, a.title AS title,"
. "\n a.created AS created, a.created_by_alias,"
//. "\n CONCAT(a.introtext, a.fulltext) AS text,"
. "\n a.introtext AS text,"
. "\n a.fulltext AS fulltextmore,"
. "\n '"._ALPHACONTENT_NOCATEGORY."' AS section,"
. $href
. "\n '2' AS browsernav,"
. "\n a.images AS images,"
. "\n a.state AS state,"
. "\n a.hits AS hits,"
. "\n a.attribs AS attribs,"
. "\n a.created_by AS created_by,"
// To usuń . "\n ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, s.name AS author"
. "\n ROUND(AVG(mxc_c.rating)) AS rating, COUNT(mxc_c.contentid) AS rating_count, s.name AS author" // To wstaw
. "\n FROM #__content AS a"
// To usuń . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id"
. "\n LEFT JOIN #__mxc_comments AS mxc_c ON mxc_c.contentid = a.id" // To wstaw
. "\n LEFT JOIN #__users AS s ON s.id = a.created_by"
. "\n $where"
. "\n AND a.sectionid = '0'"
. "\n $state"
. "\n AND a.access <= '$my->gid'"
. "\n AND ( publish_up = '$nullDate' OR publish_up <= '$now' )"
. "\n AND ( publish_down = '$nullDate' OR publish_down >= '$now' )"
. "\n GROUP BY mxc_c.contentid" // To wstaw
. "\n ORDER BY $order"
. "\nLIMIT $pageNav->limitstart, $pageNav->limit";

$database->setQuery( $query );
$rows = $database->loadObjectList();
break;
}
W tym momencie z bazy danych pobierane będą statystyki oferowane przez komponent mXcomment. Problem w tym że jak tego komponentu nie będzie, zapytanie zwracać będzie błedy.

Kolejna modyfikacje są w pliku: /components/com_alphacontent/alphacontent.html

1. Na samym początku funkcji display dodaj:


// Istniejąca linijka
require( $mosConfig_absolute_path.'/administrator/components/com_alphacontent/alphacontent_config.php' );
// Dodaj tą linijkę
require( $mosConfig_absolute_path.'/administrator/components/com_maxcomment/maxcomment_config.php' );
2. Musisz odnaleźć blok generujący statystyki, który po przeróbkach wygląda następująco:




// show rating
if ( $showrating && $row->section!='com_weblinks') {

if ( $_VERSION->PRODUCT == 'Joomla!' || $_VERSION->PRODUCT == 'a8ejoomla' ){
// look for images in template if available
$starImageOn = mosAdminMenus::ImageCheck( 'rating_star.png', '/images/M_images/' );
$starImageOff = mosAdminMenus::ImageCheck( 'rating_star_blank.png', '/images/M_images/' );
} else {
// FOR COMPLIANCE WITH MAMBO
$starImageOn = $mainframe->ImageCheck( 'rating_star.png', '/images/M_images/' );
$starImageOff = $mainframe->ImageCheck( 'rating_star_blank.png', '/images/M_images/' );
}

$img = "<span style=\"vertical-align:middle\">";
for ($c=0; $c < ($row->rating<=$mxc_levelrating?$row->rating:$mxc_levelrating); $c++) {
$img .= $starImageOn;
}
for ($c=$row->rating; $c < $mxc_levelrating; $c++) {
$img .= $starImageOff;
}
$html = $img . "</span> (";
$html .= intval( $row->rating_count );
if( $row->rating_count > 1){
$rats = _ALPHACONTENT_RATINGS;
}else{
$rats = _ALPHACONTENT_RATING;
}
$html .= " ".$rats ;
$html .= ")";
$rating = $html;
}
Wystarczy że podmienisz ten kawłek kodu.

Wersje komponentów:
MXcomment: Version 1.0.4
AlphaContent: 3.0

mjapko
09-11-2007, 14:04
zrobiłem wszystko tak jak opisałeś i nie wyświetla mi wyników, na stronie AlphaContent jest tylko komunikat brak wyników tam gdzie powinna być lista artykułów

a czy mógłbyć wysłać mi te 2 już zmienione pliki na axel77@o2.pl ?

kobylinski
09-11-2007, 14:40
Tutaj są te dwa pliki:
622

Dodatkowo powinno się wyłączyć bota mosvote.