$settings['number_recent_posts'] получить доступ со всех страниц.

Started by Ghirik, February 19, 2008, 02:43:57 AM

Previous topic - Next topic

Ghirik

Всем привет.

Я в php мало чего смыслю, на уровне JavaScript-а  :) Т.е., что с JavaScript-ом схоже, то понимаю.

Мне нужно иметь доступ к $settings['number_recent_posts'] на всех страницах форума. Как это можно сделать? Что и где прописать?

Научите пожалуйста.

Ghirik

Вопрос решил, может кому пригодится.  Добавил следующий код в файлы Sources/MessageIndex.php и Sources/Display.php:


// Load the most recent post?
if ((!empty($settings['number_recent_posts']) && $settings['number_recent_posts'] == 1) || $settings['show_sp1_info'])
$context['latest_post'] = $most_recent_topic['ref'];

if (!empty($settings['number_recent_posts']) && $settings['number_recent_posts'] > 1)
{
require_once($sourcedir . './Sources/Recent.php');

if (($context['latest_posts'] = cache_get_data('boardindex-latest_posts:' . md5($user_info['query_see_board'] . $user_info['language']), 180)) == null)
{
$context['latest_posts'] = getLastPosts($settings['number_recent_posts']);
cache_put_data('boardindex-latest_posts:' . md5($user_info['query_see_board'] . $user_info['language']), $context['latest_posts'], 180);
}

// We have to clean up the cached data a bit.
foreach ($context['latest_posts'] as $k => $post)
{
$context['latest_posts'][$k]['time'] = timeformat($post['raw_timestamp']);
$context['latest_posts'][$k]['timestamp'] = forum_time(true, $post['raw_timestamp']);
}
}


После этого, $settings['number_recent_posts'] содержит последние сообщения при загрузке любой страницы форума.



Advertisement: