Topic: Описание темы под ее именем (в списке топиков на форуме)
Расширение для генерации описания темы, позволяет автоматически выводить описание под каждой темой в списке на страницах форумов. Таким образом описание не нужно каждый раз вводить вручную. Достаточно установить расширение и определить в настройках число символов выводимых в описании.
pan_desc_on_forum/manifest.xml
▼Spoiler
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE extension SYSTEM "ext-1.0.dtd">
<!--
/**
* Description topics
* @copyright Copyright (C) 2015 PanBB
* @package pan_desc_on_forum
* @website https://punbb.softplaza.net
*/
-->
<extension engine="1.0">
<id>pan_desc_on_forum</id>
<title>Description topics</title>
<version>0.1</version>
<description>Description topics On Forums.</description>
<author>PunBB</author>
<minversion>1.4.0</minversion>
<maxtestedon>1.4.2</maxtestedon>
<install><![CDATA[
// Add extension options to the config table
forum_config_add('o_pan_desc_on', '0');
forum_config_add('o_pan_desc_num', '150');
]]></install>
<uninstall> <![CDATA[
// Delete extension options from the config
forum_config_remove(array(
'o_pan_desc_on',
'o_pan_desc_num',
));
]]></uninstall>
<hooks>
<!-- include options -->
<hook id="aop_features_gzip_fieldset_end"><![CDATA[
?>
<div class="content-head">
<h2 class="hn"><span>Описание тем</span></h2>
</div>
<legend class="group-legend"><strong><?php echo $lang_admin_settings['Features update legend'] ?></strong></legend>
<div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box checkbox">
<input type="hidden" name="form[pan_desc_on]" value="0" />
<span class="fld-input"><input type="checkbox" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[pan_desc_on]" value="1"<?php if ($forum_config['o_pan_desc_on'] == '1') echo ' checked="checked"' ?> /></span>
<label for="fld<?php echo $forum_page['fld_count'] ?>"><span>Включить</span>Отображать описание в списке тем на форуме</label>
</div>
</div>
<div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box text">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span>Кол-во символов</span><small>Введите число, сколько символов выводить в описании.</small></label><br />
<span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[pan_desc_num]" size="10" maxlength="3" value="<?php echo forum_htmlencode($forum_config['o_pan_desc_num']) ?>" required /></span>
</div>
</div>
<?php
]]></hook>
<hook id="vf_row_pre_item_subject_merge"><![CDATA[
if($forum_config['o_pan_desc_on'] == '1')
{
//Description topics
$query2 = array(
'SELECT' => 'p.topic_id, p.message',
'FROM' => 'posts AS p',
'WHERE' => 'p.id = '.$cur_topic['first_post_id'].'',
);
$result2 = $forum_db->query_build($query2) or error(__FILE__, __LINE__);
$cur_posts = $forum_db->fetch_assoc($result2);
//strip message
$desc_topic = $cur_posts['message'];
// $desc_topic = strip_tags($desc_topic);
$desc_topic = substr($desc_topic, 0, $forum_config['o_pan_desc_num']);
$desc_topic = rtrim($desc_topic, "!,.-");
$desc_topic = substr($desc_topic, 0, strrpos($desc_topic, ' '));
$desc_topic = (preg_replace('/[hide|b|i|u||quote|code|img|url|email|list|color|video|spoiler|h||)]/', '', $desc_topic));
$desc_topic = preg_replace('/[^a-zа-яё., ]+/iu', '', $desc_topic);
$forum_page['item_body']['subject']['topic_desc'] = '<p><small>'.forum_htmlencode($desc_topic).'</small></p>';
}
]]></hook>
</hooks>
</extension>