Domanda:
Risposta:Adam_T ha scritto:Nei risultati di ricerca (soprattutto in messaggi non letti) vorrei inserire il nome della categoria primo post Topic:
[Category_1] Test_post_2
[Category_2] Test_post_4
[Category_2] Test_post_5
ecc
Qualche suggerimento su come farlo? Si prega di aiutare
AmigoJack ha scritto:Tenete a mente che questo avrà un impatto sul database in più, dal momento che per ogni forum il genitore deve essere trovata, e poi il genitore del genitore di nuovo ... fino a quando un forum non ha più alcun genitore. Un forum non è memorizzato l'intero percorso con esso.
Apri /search.php è cerca:Aggiungi prima:Codice: Seleziona tutto
foreach ($rowset as $row)
Trova:Codice: Seleziona tutto
/*** 2011-03-21 BEGIN AmigoJack Show forum path for every result. Be aware that this impacts the database since we need to know each parent of a forum until we reach a forum which has no parent anymore. ***/ $aForumData= $aForumFind= $aForumPath= array(); // We need to query the parent of all forums from this results page foreach( $rowset as $aRow ) { $aForumFind[]= $aRow['forum_id']; $aForumPath[$aRow['forum_id']]= ''; // These are our targets } // Should be encountered at least once while( count( $aForumFind ) ) { $sql= 'SELECT forum_id, forum_name, parent_id FROM '. FORUMS_TABLE. ' WHERE '. $db-> sql_in_set( 'forum_id', $aForumFind ); $rSql= $db-> sql_query( $sql ); // Reset since we will fill it again with the parents of the query results $aForumFind= array(); while( $aRow= $db-> sql_fetchrow( $rSql ) ) { $aForumData[$aRow['forum_id']]= $aRow; // Expand our knowledge if( $aRow['parent_id'] ) $aForumFind[]= $aRow['parent_id']; // Has a parent? Loop at least once more } $db-> sql_freeresult( $rSql ); } // Now build the paths foreach( $aForumPath as $k1=> $v1 ) { $iForum= $k1; $aForumPath[$k1]= $aForumData[$iForum]['forum_name']; // Walk from child to his ancestors while( $aForumData[$iForum]['parent_id'] ) { $iForum= (int)$aForumData[$iForum]['parent_id']; $aForumPath[$k1]= $aForumData[$iForum]['forum_name']. ' <strong>‹</strong> '. $aForumPath[$k1]; } } /*** 2011-03-21 END ***/
Sostituire con:Codice: Seleziona tutto
'FORUM_TITLE' => $row['forum_name'],
Testato.Codice: Seleziona tutto
/*** 2011-03-21 BEGIN AmigoJack Full forum path instead of title only ***/ //'FORUM_TITLE' => $row['forum_name'], 'FORUM_TITLE' => $aForumPath[$forum_id], /*** 2011-03-21 END ***/