Для отображения последних тем форума (групп форумов) необходимо:
1) создать динамическую страницу следующего содержания
<?php
$DataBase = & singleton('DataBase');
$Forums = & singleton('Forums');
// Идентификатор конференции
$conference_id = 1;
// Число отображаемых тем форума
$items_on_page = 5;
$xslname = 'ТемыФорума';
$XMLcode = '<?xml version="1.0" encoding="' . SITE_CODING . '"?>'."\n";
$XMLcode .= '<document>' . "\n";
$XMLcode .= '<conference_id>' . $conference_id . '</conference_id>'."\n";
/* Получаем данные о конференции*/
$conference_row = $Forums->GetConference($conference_id);
/* Конференция с указанным кодом найдена*/
if ($conference_row)
{
/* Определяем путь к конференции по идентификатору стркутуры*/
$path = $Forums->GetConferencePath($conference_id);
// Путь к форуму - константа из конфига форума для правильного отображения ссылок
$XMLcode .= '<forums_path>' . str_for_xml($path) . '</forums_path>' . "\n";
// Массив идентификаторов форумов
$forums_array = array();
// Получаем список форумов, входящих в конференцию
$forums_groups_resource = $Forums->GetAllForumsGroup($conference_id);
// Цикл по группам форумов
while ($forums_group_row = mysql_fetch_array($forums_groups_resource))
{
// Получаем список форумов для каждой группы
$forums_resource = $Forums->GetAllForums($forums_group_row['forums_group_id']);
// Цикл по форумам группы
while ($forum_row = mysql_fetch_array($forums_resource))
{
$forums_array[] = $forum_row['forums_id'];
}
}
$rows = $Forums->SelectFormThemes($forums_array, 0, $items_on_page);
$XMLcode .= '<current_page>0</current_page>' . "\n"; // Как вводить текущую страницу
$XMLcode .= '<items_on_page>' . $items_on_page . '</items_on_page>' . "\n"; // Как вводить текущую страницу
$XMLcode .= '<messages_on_page>' . $conference_row['forums_conference_on_page_message'] . '</messages_on_page>' . "\n";
while ($row = mysql_fetch_assoc($rows))
{
$XMLcode .= $Forums->GenXml4Theme($row['forums_theme_id'], false, $row);
}
}
$XMLcode .= '</document>' . "\n";
//echo nl2br(htmlspecialchars($XMLcode));
$xsl = new xsl();
echo $xsl->build($XMLcode, $xslname);
?>
2) Создать XSL-шаблон с названием 'ТемыФорума'. Код шаблона
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="Windows-1251" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<!-- ТемыФорума -->
<xsl:template match="/document">
<form action="{/document/forums_path}" method="post">
<table class="table_forum" cellpadding="0" cellspacing="0">
<tr id="data">
<td>
<!-- Шапка параметров тем -->
<table class="table_themes">
<tr class="row_title_themes">
<td align="center" class="theme_td_attribute"></td>
<td align="center" class="theme_td_title">Тема</td>
<td align="center" class="theme_td_author">Автор</td>
<td align="center" class="theme_td_count_answer">Ответов</td>
<td align="center" class="theme_td_last_message">Последнее сообщение</td>
<!-- Поле действий для модератора -->
<xsl:if test="moderator = 1">
<td align="center" class="theme_td_action">
<b>Действие</b>
</td>
</xsl:if>
</tr>
<!-- Если есть темы для форума -->
<xsl:if test="not(count(forums_theme)=0)">
<xsl:apply-templates select="forums_theme[theme_visible=1]"/>
</xsl:if>
</table>
</td>
</tr>
</table>
</form>
</xsl:template>
<!-- Строка ссылок на в теме -->
<xsl:template name="pages">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<xsl:param name="current_page"/>
<xsl:param name="theme_id"/>
<xsl:if test="$n > $i">
<!-- Определяем адрес ссылки -->
<xsl:choose>
<!-- Если число страниц меньше 7 и больше 1 -->
<xsl:when test="7 > $n">
<xsl:variable name="number_link">
<xsl:choose>
<!-- Если не нулевой уровень -->
<xsl:when test="$i != 0">page-<xsl:value-of select="$i + 1"/>/</xsl:when>
<!-- Иначе если нулевой уровень - просто ссылка на страницу со списком элементов -->
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Ставим ссылку на страницу-->
<a href="{/document/forums_path}{/document/forums_id}/{$theme_id}/{$number_link}">
<xsl:value-of select="$i + 1"/>
</a>
<xsl:if test="$n - 1 > $i ">,</xsl:if>
<!-- Рекурсивный вызов шаблона. НЕОБХОДИМО ПЕРЕДАВАТЬ ВСЕ НЕОБХОДИМЫЕ ПАРАМЕТРЫ! -->
<xsl:call-template name="pages">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="n" select="$n"/>
<xsl:with-param name="current_page" select="$current_page"/>
<xsl:with-param name="theme_id" select="$theme_id"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<a href="{/document/forums_path}{/document/forums_id}/{$theme_id}/">1</a>,
<a href="{/document/forums_path}{/document/forums_id}/{theme_id}/page-2/">2</a>,
<a href="{/document/forums_path}{/document/forums_id}/{theme_id}/page-3/">3</a>...
<a href="{/document/forums_path}{/document/forums_id}/{theme_id}/page-{$n - 2}/">
<xsl:value-of select="$n - 2"/>
</a>,
<a href="{/document/forums_path}{/document/forums_id}/{theme_id}/page-{$n - 1}/">
<xsl:value-of select="$n - 1"/>
</a>,
<a href="{/document/forums_path}{/document/forums_id}/{theme_id}/page-{$n}/">
<xsl:value-of select="$n"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- Шаблон вывода строк тем -->
<xsl:template match="forums_theme">
<!-- Стиль строки -->
<xsl:variable name="color_theme">
<xsl:choose>
<xsl:when test="(position() mod 2 = 0) and not ((//moderator=1) and (theme_visible=0))">color_2_theme</xsl:when>
<xsl:when test="(//moderator=1) and (theme_visible=0)">color_hidden_theme</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Отображаем тему если она не скрытая или/и пользвоатель - модератор -->
<xsl:if test="theme_visible=1">
<tr class="{$color_theme}">
<!-- Атрибуты темы -->
<td align="center" class="theme_td_attribute">
<xsl:if test="theme_close=1 and theme_notice=0 and theme_new=1">
<img src="/hostcmsfiles/forum/theme_locked_new.gif" title="Закрытая тема с непрочитанными сообщениями" alt="X+"/>
</xsl:if>
<xsl:if test="theme_close=1 and theme_notice=0 and theme_new=0">
<img src="/hostcmsfiles/forum/theme_locked.gif" title="Закрытая тема без непрочитанных сообщений" alt="X-"/>
</xsl:if>
<xsl:if test="theme_close=0 and theme_notice=1 and theme_new=1">
<img src="/hostcmsfiles/forum/theme_notice_new.gif" title="Открытое объявление с непрочитанными сообщениями" alt="O!+"/>
</xsl:if>
<xsl:if test="theme_close=0 and theme_notice=1 and theme_new=0">
<img src="/hostcmsfiles/forum/theme_notice.gif" title="Открытое объявление без непрочитанных сообщений" alt="O!-"/>
</xsl:if>
<xsl:if test="theme_close=1 and theme_notice=1 and theme_new=1">
<img src="/hostcmsfiles/forum/theme_notice_close_new.gif" title="Закрытое объявление с непрочитанными сообщениями" alt="X!+"/>
</xsl:if>
<xsl:if test="theme_close=1 and theme_notice=1 and theme_new=0">
<img src="/hostcmsfiles/forum/theme_notice_close.gif" title="Закрытое объявление без непрочитанных сообщений" alt="X!-"/>
</xsl:if>
<xsl:if test="theme_notice=0 and theme_close=0 and theme_new=1">
<img src="/hostcmsfiles/forum/theme_new.gif" title="Тема с непрочитанными сообщениями" alt="O+"/>
</xsl:if>
<xsl:if test="theme_notice=0 and theme_close=0 and theme_new=0">
<img src="/hostcmsfiles/forum/theme.gif" title="Тема без непрочитанных сообщений" alt="O-"/>
</xsl:if>
</td>
<!-- Если тема - объявление, выводим жирным -->
<xsl:variable name="style_theme_name">
<xsl:choose>
<xsl:when test="theme_notice = 1">font-weight: bold</xsl:when>
<!-- Закрытая тема выводится зачеркнутым -->
<xsl:when test="theme_close = 1">text-decoration: line-through</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Заголовок темы -->
<td class="theme_td_title">
<a href="{/document/forums_path}{forum_id}/{theme_id}/" style="{$style_theme_name}">
<xsl:value-of select="theme_title"/>
</a>
<!-- Число страниц с ответами темы -->
<xsl:variable name="count_message_page" select="ceiling((theme_count_reply + 1) div //messages_on_page)"/>
<xsl:choose>
<!-- Если число больше 1 -->
<xsl:when test="$count_message_page > 1">(<xsl:call-template name="pages">
<xsl:with-param name="n" select="$count_message_page"/>
<xsl:with-param name="current_page" select="//current_page"/>
<xsl:with-param name="theme_id" select="theme_id"/></xsl:call-template>)</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</td>
<td align="center" class="theme_td_author">
<xsl:choose>
<!-- Если число страниц меньше 7 и больше 1 -->
<xsl:when test="theme_author=''">
<b>Гость</b>
</xsl:when>
<xsl:otherwise>
<a href="/users/info/{theme_author}/">
<xsl:value-of select="theme_author"/>
</a>
</xsl:otherwise>
</xsl:choose>
<!-- Дата создания темы -->
<br/>
<xsl:value-of select="theme_datetime"/>
</td>
<!-- Количество ответов в теме -->
<td align="center" class="theme_td_count_answer">
<xsl:value-of select="theme_count_reply"/>
</td>
<!-- Последнее сообщение в теме -->
<td align="center" class="theme_td_last_message">
<!-- Автор последнего сообщения -->
<xsl:if test="theme_last_message/message_author=''">
<b>Гость</b>
</xsl:if>
<xsl:if test="theme_last_message/message_author!=''">
<a href="/users/info/{theme_last_message/message_author}/">
<xsl:value-of select="theme_last_message/message_author"/>
</a>
</xsl:if>
<br/>
<!-- Дата последнего сообщения -->
<xsl:value-of select="theme_last_message/message_datetime"/>
</td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>