Уважаемые пользователи!
C 7 ноября 2020 года phpBB Group прекратила выпуск обновлений и завершила дальнейшее развитие phpBB версии 3.2.
С 1 августа 2024 года phpBB Group прекращает поддержку phpBB 3.2 на официальном сайте.
Сайт официальной русской поддержки phpBB Guru продолжит поддержку phpBB 3.2 до 31 декабря 2024 года.
С учетом этого, настоятельно рекомендуется обновить конференции до версии 3.3.

[3.1] Определенная тема(топик) с форума на сайте

У вас есть идея для расширения функциональности phpBB? Расскажите о ней здесь!
Правила форума
Местная Конституция | Шаблон запроса | Документация (phpBB3) | Мини [FAQ] по phpBB3.1.x/3.3.x | FAQ | Как задавать вопросы | Как устанавливать расширения

Ваш вопрос может быть удален без объяснения причин, если на него есть ответы по приведённым ссылкам (а вы рискуете получить предупреждение ;) ).
iliyasuper
phpBB 1.0.0
Сообщения: 5
Стаж: 5 лет 11 месяцев
Благодарил (а): 1 раз

[3.1] Определенная тема(топик) с форума на сайте

Сообщение iliyasuper »

Здравствуйте, сразу прошу прощение если не уследил свой вопрос на форуме.
Пытался, искал, может плохо.. Перечитал 69 страниц темы о прилоэении recent topic for 3.0 - не нашел подходящего ответа.
Суть вопроса в том, что - есть сайт, есть форум phpbb 3.1.7.
Скрипт с темы [final] Recent topics for phpBB3 (Темы на стр. сайта) прекрасно работает.

Подскажите, как можно модифицировать скрипт чтоб выводил какой то определенный топик, который я укажу?
в настрйоках можно выбрать форум, но не топик

Код: Выделить всё

$cfg_ignore_forums = ''; 		// ids of forums you don't want to display, separated by commas or empty
[b]$cfg_only_forums = '3'; // ids of forums you only want to display, separated by commas or empty[/b]
$cfg_nm_topics = 1;			// number of topics to output
$cfg_max_topic_length = 120; 	// max topic length, if more, title will be shortened
$cfg_show_replies = false; 		// show number of replies to topics
$cfg_show_first_post = true;	// show first posts of the recent topics
$cfg_show_attachments = true;	// show attachments in the first posts of recent topics
То есть мне нужно вывести определенный топик с его содержимым и вложениями на мой сайт.
Подскажите пожалуйста как это реализовать?

вот сам скрипт, модифицированный(нашел инфу на этом форуме) под версию 3.1.*

Код: Выделить всё

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/** 
*
* @package phpBB3
* @version $Id: recent.php,v 1.1.2 2007/08/21 23:21:39 rxu Exp $
* @copyright (c) 2005 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/!

/* Config section */

$cfg_ignore_forums = ''; 		// ids of forums you don't want to display, separated by commas or empty
$cfg_only_forums = '3'; // ids of forums you only want to display, separated by commas or empty
$cfg_nm_topics = 1;			// number of topics to output
$cfg_max_topic_length = 120; 	// max topic length, if more, title will be shortened
$cfg_show_replies = false; 		// show number of replies to topics
$cfg_show_first_post = true;	// show first posts of the recent topics
$cfg_show_attachments = true;	// show attachments in the first posts of recent topics
/* End of config */

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

//
// Let's prevent caching
//
$server_software = $request->server('SERVER_SOFTWARE');
if (!empty($server_software) && strstr($request->server('SERVER_SOFTWARE'), 'Apache/2'))
{
	header ('Cache-Control: no-cache, pre-check=0, post-check=0');
}
else
{
	header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header('Content-type: text/html; charset=UTF-8');
header('Expires: 0');
header('Pragma: no-cache');

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

//
// Building URL
//

$board_path = generate_board_url();
$viewtopic_url = $board_path . '/viewtopic.' . $phpEx;

// Fetching forums that should not be displayed
$forums = implode(',', array_keys($auth->acl_getf('!f_read', true)));
$cfg_ignore_forums = (!empty($cfg_ignore_forums) && !empty($forums)) ? $cfg_ignore_forums . ',' . $forums : ((!empty($forums)) ? $forums : ((!empty($cfg_ignore_forums)) ? $cfg_ignore_forums : ''));

// Building sql for forums that should not be displayed
$sql_ignore_forums = (!empty($cfg_ignore_forums)) ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums .') ' : '';

// Building sql for forums that should only be displayed
$sql_only_forums = (!empty($cfg_only_forums)) ? ' AND t.forum_id IN(' . $cfg_only_forums .') ' : '';

// Fetching topics of public forums
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_last_post_id, t.topic_first_post_id, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment
	FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f
	WHERE t.forum_id = f.forum_id
		$sql_ignore_forums
		$sql_only_forums 
		AND p.post_id = t.topic_first_post_id
		AND t.topic_moved_id = 0
	ORDER BY t.topic_last_post_id DESC LIMIT $cfg_nm_topics";

$result = $db->sql_query($sql);

$recent_topics = $db->sql_fetchrowset($result);

//
// BEGIN ATTACHMENT DATA
//
if($cfg_show_first_post && $cfg_show_attachments)
{
	$attach_list = $update_count = array();
	foreach ($recent_topics as $post_attachment)
	{
		if ($post_attachment['post_attachment'] && $config['allow_attachments'])
		{
			$attach_list[] = $post_attachment['post_id'];

			if ($post_attachment['post_approved'])
			{
				$has_attachments = true;
			}
		}
	}

	// Pull attachment data
	if (sizeof($attach_list))
	{
		if ($auth->acl_get('u_download') )
		{
			$sql_attach = 'SELECT *
				FROM ' . ATTACHMENTS_TABLE . '
				WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
					AND in_message = 0
				ORDER BY filetime DESC, post_msg_id ASC';
			$result_attach = $db->sql_query($sql_attach);

			while ($row_attach = $db->sql_fetchrow($result_attach))
			{
				$attachments[$row_attach['post_msg_id']][] = $row_attach;
			}
			$db->sql_freeresult($result_attach);
		}
		else
		{
			$display_notice = true;
		}
	}
}
//
// END ATTACHMENT DATA
//

foreach ( $recent_topics as $row )
{
	$topic_title = censor_text($row['topic_title']);
	$topic_title = (utf8_strlen($topic_title) > $cfg_max_topic_length) ? utf8_substr($topic_title, 0, $cfg_max_topic_length) . '&hellip;' : $topic_title;
	$topic_title = str_replace(array("\r\n", "\r", "\n"), '<br />', $topic_title);
	$topic_title = addslashes($topic_title);
	
	// Replies
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
	$replies = $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1;

	// Instantiate BBCode if need be
	if ($row['bbcode_bitfield'] !== '')
	{
		$bbcode = new bbcode(base64_encode($row['bbcode_bitfield']));
	}

	$message = $row['post_text'];

	// Parse the message
	$message = censor_text($message);

	// Second parse bbcode here
	if ($row['bbcode_bitfield'])
	{
		$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
	}

	$message = str_replace("\n", '<br />', $message);

	// Always process smilies after parsing bbcodes
	$message = smiley_text($message);
	
	// Parse attachments
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		parse_attachments($row['forum_id'], $message, $attachments[$row['post_id']], $update_count);
	}
	
	$message = str_replace(array("\r\n", "\r", "\n"), '<br />', $message);
	$message = addslashes($message);
	$message = str_replace('./', $board_path . '/', $message);
	$tags = array('dl', 'dt', 'dd');
	$message = strip_selected_tags($message, $tags);
	
	
	$template->assign_block_vars('topicrow', array( 
		'U_TOPIC' 		=> $viewtopic_url . '?f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'] . '&amp;view=unread#unread' ,
		'TOPIC_TITLE' 	=> $topic_title , 
		'TOPIC_REPLIES'	=> ($cfg_show_replies) ? '[' . $replies . '] ' : '',
		'S_HAS_ATTACHMENTS'		=> ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']])) ? true : false,
	));

	if ($cfg_show_first_post)
	{
		$template->assign_block_vars('topicrow.first_post_text', array(
			'TOPIC_FIRST_POST_TEXT' => ($cfg_show_first_post) ? '<span style="color:white">' . $message . '</span>' : ''
		));
	}

	// Display not already displayed Attachments for this post, we already parsed them. ;)
	if ($cfg_show_first_post && $cfg_show_attachments && !empty($attachments[$row['post_id']]))
	{
		foreach ($attachments[$row['post_id']] as $attachment)
		{
			$attachment = str_replace(array("\r\n", "\r", "\n"), '<br />', $attachment);
			$attachment = str_replace('"./', '"' . $board_path . '/', $attachment);
			$tags = array('span', 'dt', 'dd');
			$attachment = strip_selected_tags($attachment, $tags);

			$template->assign_block_vars('topicrow.first_post_text.attachment', array(
				'DISPLAY_ATTACHMENT'	=>  $attachment)
			);
		}
	}

}
$db->sql_freeresult($result);
		
//
// Load template
//
$template->set_filenames(array(
	'body' => 'recent_body.html')
);

//
// Output
//
$template->display('body');



/**
* Works like PHP function strip_tags, but it only removes selected tags.
* Example: * strip_selected_tags('<b>Person:</b> <strong>Larcher</strong>', 'strong') => <b>Person:</b> Larcher
* by Matthieu Larcher 
* http://ru2.php.net/manual/en/function.strip-tags.php#76045
*/
function strip_selected_tags($text, $tags = array())
{
	$args = func_get_args();
	$text = array_shift($args);
	$tags = (func_num_args() > 2) ? array_diff($args,array($text)) : (array)$tags;
	foreach ($tags as $tag)
	{
		while(preg_match('/<'.$tag.'(|\W[^>]*)>(.*)<\/'. $tag .'>/iusU', $text, $found))
		{
			$text = str_replace($found[0],$found[2],$text);
		}
	}

	return preg_replace('/(<('.join('|',$tags).')(|\W.*)\/>)/iusU', '', $text);
}


?>
Спасибо
Аватара пользователя
nissin
phpBB 3.0.4
Сообщения: 2208
Стаж: 16 лет 3 месяца
Откуда: Павлодар
Благодарил (а): 7 раз
Поблагодарили: 338 раз
Контактная информация:

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение nissin »

Для 3.1 есть аналогичное расширение Recent topics for JS
http://bb3.mobi/forum/viewtopic.php?t=80
Для вашей задачи, всё же нужно написать отдельное расширение.
Всё повторяется. nurlan.info
iliyasuper
phpBB 1.0.0
Сообщения: 5
Стаж: 5 лет 11 месяцев
Благодарил (а): 1 раз

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение iliyasuper »

А нельзя прям указать URL темы которую надо вывести? Так мне тоже подошло бы
iliyasuper
phpBB 1.0.0
Сообщения: 5
Стаж: 5 лет 11 месяцев
Благодарил (а): 1 раз

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение iliyasuper »

Подскажите пожалуйста как это реализовать. Немогу найти переменную обращения к топику.
Или как этот скрипт ищет id топика ? Может возможно указать ему где-т id - прямо?
alexgearbox
phpBB 1.4.4
Сообщения: 116
Стаж: 13 лет 10 месяцев
Благодарил (а): 82 раза
Поблагодарили: 13 раз
Контактная информация:

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение alexgearbox »

Можно было бы использовать фид темы и BuzzBoost Google Feedburner.
Здесь все админы. Админы своих форумов. © Mr. Anderson
iliyasuper
phpBB 1.0.0
Сообщения: 5
Стаж: 5 лет 11 месяцев
Благодарил (а): 1 раз

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение iliyasuper »

alexgearbox писал(а): 27.04.2018 16:19 Можно было бы использовать фид темы и BuzzBoost Google Feedburner.
Спасибо, отличная идея, попробовал ввёл тему которая мне нужна с форума, гугл выдал мне

Код: Выделить всё

Мы не смогли обнаружить действующего фида по данному адресу. Вот несколько причин произошедшего:
оооочень надо, помогите пожалуйста, неделю бьюсь уже :D
alexgearbox
phpBB 1.4.4
Сообщения: 116
Стаж: 13 лет 10 месяцев
Благодарил (а): 82 раза
Поблагодарили: 13 раз
Контактная информация:

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение alexgearbox »

Указали адрес темы, а не адрес её фида?

Адрес темы:

Код: Выделить всё

https://www.phpbbguru.net/community/viewtopic.php?f=65&t=48686
Адрес фида:

Код: Выделить всё

https://www.phpbbguru.net/community/feed/topic/48686
И в настройках форума нужно, конечно, разрешить фиды для отдельных тем.
Здесь все админы. Админы своих форумов. © Mr. Anderson
iliyasuper
phpBB 1.0.0
Сообщения: 5
Стаж: 5 лет 11 месяцев
Благодарил (а): 1 раз

Re: [3.1] Определенная тема(топик) с форума на сайте

Сообщение iliyasuper »

Разобрался, вот в таком виде ссылка - работает, но feed burner не видет ее не как...

Код: Выделить всё

http://e46fanatics.com.ua/forum/feed.php?f=3&t=5


А как мне это дело теперь выложить на сайт?

Отправлено спустя 33 минуты 5 секунд:
Почитал, на phpbb используется atom, увы познаний не хватает как его выложить на сайт (((
opera открывает мой линк http://e46fanatics.com.ua/forum/feed.php?f=3&t=5 но немножко не так

вот как я сделал последнии новости на сайт http://e46fanatics.com.ua/news.html
Но тут показывает именно последнюю новость. А нужно указать именно конкретную тему чтобю в таком виде показывало
Перенесено из форума Поддержка расширений для phpBB в форум Запросы расширений для phpBB 28.04.2018 19:17 модератором rxu

Ответить

Вернуться в «Запросы расширений для phpBB»