Aktualizowałem forum z 3.1.5 do 3.1.7 i oczywiście moje modyfikacje kodu szlag trafił. Musiałem znów ręcznie doklejać utracone kawałki, więc na bieżąco wiem jak tworzy się panel

1) W pliku index.php przelatuję bazę wybierając interesujące mnie dane. Tu są to ostatnie tematy z wybranych forów, ale w dwóch kolumnach. W pierwszej kolumnie mogą być wszystkie fora, w drugiej kolumnie, tylko 1-2 wybrane:
Kod: Zaznacz cały
// generuje ostatnie tematy
$sql = 'SELECT forum_id, topic_title, topic_views, topic_last_poster_id, topic_last_poster_name, topic_poster, topic_first_poster_name, topic_last_post_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' WHERE forum_id NOT IN (0,2,5,7,8,9,14,40,42,43,68,70,75,76,77,78,79,80,81,98,99,100,101,102,103,104,105,106,107) ORDER BY topic_last_post_time DESC LIMIT 0 , 10';
$result = $db->sql_query($sql);
$i=0;
while($row = mysql_fetch_array($result))
{
$sql1 = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = '.$row['forum_id'];
$result1 = $db->sql_query($sql1);
$row['forum_name'] = mysql_result($result1, 0);
$db->sql_freeresult($result1);
$out_forum = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=".$row['forum_id']);
$out_forum = '[<a href="'.$out_forum.'" target="_blank">'. $row['forum_name'] .'</a>] ';
$out_title = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=".$row['forum_id']."&p=".$row['topic_last_post_id']."#p".$row['topic_last_post_id']);
$out_title = '<a class ="lastsubject" href="'.$out_title.'" target="_blank">'. $row['topic_title'] .'</a>';
$out_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u='. $row['topic_last_poster_id']);
$out_poster = ' [<a class ="lastsubject" href="'.$out_poster.'" target="_blank">'. $row['topic_last_poster_name'] .'</a>]';
$out_post_date = date("d-m-Y, H:i",$row['topic_last_post_time']);
//$template->assign_block_vars('temat', array(
$temp1[$i] = array(
'OUT_FORUM' => $out_forum,
'OUT_TITLE' => $out_title,
'OUT_POSTER' => $out_poster,
'OUT_DATA' => $out_post_date,
);
$i++;
}
$db->sql_freeresult($result);
// generuje ostatnie tematy
$sql = 'SELECT forum_id, topic_title, topic_views, topic_last_poster_id, topic_last_poster_name, topic_poster, topic_first_poster_name, topic_last_post_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' WHERE forum_id IN (5,7,8,9,98,99,100,101,102,103) ORDER BY topic_last_post_id DESC LIMIT 0 , 10';
$result = $db->sql_query($sql);
$i=0;
while($row = mysql_fetch_array($result))
{
$sql1 = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE forum_id = '.$row['forum_id'];
$result1 = $db->sql_query($sql1);
$row['forum_name'] = mysql_result($result1, 0);
$db->sql_freeresult($result1);
$out_forum = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=".$row['forum_id']);
$out_forum = '[<a href="'.$out_forum.'" target="_blank">'. $row['forum_name'] .'</a>] ';
$out_title = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=".$row['forum_id']."&p=".$row['topic_last_post_id']."#p".$row['topic_last_post_id']);
$out_title = '<a class ="lastsubject" href="'.$out_title.'" target="_blank">'. $row['topic_title'] .'</a>';
$out_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u='. $row['topic_last_poster_id']);
$out_poster = ' [<a class ="lastsubject" href="'.$out_poster.'" target="_blank">'. $row['topic_last_poster_name'] .'</a>]';
$out_post_date = date("d-m-Y, H:i",$row['topic_last_post_time']);
$temp2[$i] = array(
'OUT_FORUM' => $out_forum,
'OUT_TITLE' => $out_title,
'OUT_POSTER' => $out_poster,
'OUT_DATA' => $out_post_date,
);
$i++;
}
$db->sql_freeresult($result);
Nie jestem biegły w php, więc kod może niezbyt piękny - może dałoby się to "wyłuskać" w jednym zapytaniu do bazy.
2) Wybieram sobie 10 pierwszych tematów i formuję zmienne wysyłane do templatki:
Kod: Zaznacz cały
for($i=0;$i<10;$i++)
{
$template->assign_block_vars('temat', array(
'OUT_FORUM' => $temp1[$i]['OUT_FORUM'],
'OUT_TITLE' => $temp1[$i]['OUT_TITLE'],
'OUT_POSTER' => $temp1[$i]['OUT_POSTER'],
'OUT_DATA' => $temp1[$i]['OUT_DATA'],
'OUT1_FORUM' => $temp2[$i]['OUT_FORUM'],
'OUT1_TITLE' => $temp2[$i]['OUT_TITLE'],
'OUT1_POSTER' => $temp2[$i]['OUT_POSTER'],
'OUT1_DATA' => $temp2[$i]['OUT_DATA'],
));
}
3) W pliku index_body.html, przed <!-- INCLUDE forumlist_body.html --> wstawiam
Kod: Zaznacz cały
<div class="forumbg forumbg-table">
<div class="inner">
<table class="table1" show-header responsive>
<thead>
<tr>
<th>Temat</th>
<th>Autor</th>
<th>Temat</th>
<th>Autor</th>
</tr>
</thead>
<tbody>
<!-- BEGIN temat -->
<tr class="bg1">
<td class="forum1">{temat.OUT_TITLE}</br>w: {temat.OUT_FORUM}</td>
<td class="poster1">{temat.OUT_POSTER}</br>{temat.OUT_DATA}</td>
<td class="forum1">{temat.OUT1_TITLE}</br>w: {temat.OUT1_FORUM}</td>
<td class="poster1">{temat.OUT1_POSTER}</br>{temat.OUT1_DATA}</td>
</tr>
<!-- END temat -->
</tbody>
</table>
</div>
</div>
I mam swój kawałek panela na stronie głównej. Mógłbym jeszcze wyrzucić kod html do osobnego pliku i wstawić go przez <!-- INCLUDE moj_plik.html -->
To najprostszy i niezbyt ładny sposób.