Тема такая: есть динамически генерируемый список (даже не список а перечень через <br>). Собственно - вывод некоторого количества последних тем форума на Главной странице сайта (типа как на http://mweb.ru только без подробностей).
Есть возможность (и похоже, необходимость) разбить этот список на 2 колонки - ширина общей таблицы в 2 раза больше, чем нужно, выравнивание по левому краю. Правая половина пустует). Сама проблема вот тут
Скрипт генерирует этот список, просто исходя из условленного количества пунктов. Пропишешь 100 - будет показывать все 100. Сейчас показано 15. Хочу показать 20, но разбить на 2 колонки. Как?
P.S. форум обычный - phpBB 2.0.22
Используемый мод - recent_topics_1.0.4
Там всего 2 файла: 1-й - recent.php (в корне форума)
- Код: Выделить всё
<?php
/***************************************************************************
* recent.php
* -------------------
* begin : Saturday, Mar 05, 2005
* copyright : (C) 2005 Xpert
* email : xpert@phpbbguru.net
*
* $Id: recent.php,v 1.0.4 2005/08/03 20:54:00 xpert Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/* Config section */
$cfg_ignore_forums = '0'; // ids of forums you don't want to display, separated by commas
$cfg_nm_topics = 15; // number of topics to output
$cfg_max_topic_length = 50; // max topic length, if more, title will be shortened
/* End of config */
define('IN_PHPBB', true);
$phpbb_root_path = '';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
//
// Building URL
//
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ($script_name != '') ? $script_name . '/viewtopic.'.$phpEx : 'viewtopic.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';
$viewtopic_url = 'http://beloostrov.ru/' . $script_name;
//
// Session management
// I don't want to log user in, so let's trick
//
$sql = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = ". ANONYMOUS;
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not obtain anonymous data from user table', '', __LINE__, __FILE__, $sql);
}
$userdata = $db->sql_fetchrow($result);
init_userprefs($userdata);
//
// Load template
//
$template->set_filenames(array(
'body' => 'recent_body.tpl')
);
// Fetching topics of public forums
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id
FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . FORUMS_TABLE . " AS f
WHERE t.forum_id = f.forum_id
AND f.auth_read = " . AUTH_ALL . "
AND t.forum_id NOT IN(" . $cfg_ignore_forums .")
AND p.post_id = t.topic_last_post_id
AND t.topic_moved_id = 0
ORDER BY p.post_id DESC LIMIT $cfg_nm_topics";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not fetch recent topics information.", '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$topic_title = $row['topic_title'];
if ( count($orig_word) )
{
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
}
$topic_title = ( strlen($topic_title) > $cfg_max_topic_length ) ? substr($topic_title, 0, $cfg_max_topic_length) . '…' : $topic_title;
$template->assign_block_vars('topicrow', array(
'U_TOPIC' => $viewtopic_url . '?' . POST_TOPIC_URL . '=' . $row['topic_id'],
'TOPIC_TITLE' => $topic_title
));
}
//
// Output
//
$template->pparse('body');
?>
2-й - темплейт recent_body.tpl
- Код: Выделить всё
<!-- BEGIN topicrow -->
document.writeln('- <a href="{topicrow.U_TOPIC}">{topicrow.TOPIC_TITLE}</a><br />\n');
<!-- END topicrow -->
И в тело страницы вставляется код:
- Код: Выделить всё
<script language='JavaScript' type='text/javascript' src='/forum/recent.php'></script>