Topic: Add an additional field in "Post New Topic"

Can someone teach me how to create an additional field for "Post new topic" only this field would be hidden from everyone except for administrator.

The additional field would be the same as the field for "write message".

I really would appreciate your help with this.

Re: Add an additional field in "Post New Topic"

KANekT wrote an extension for adding a topic description - so that's very similiar to what you want.

Here's how his extension manifest looked. Best to probably ask him to code it for you? Maybe offer him a small token of appreciation big_smile

[code=xml]
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* manifest file for topic description
*
* @copyright Copyright (C) KANekT @ http://blog.kanekt.ru
* @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
* Donate Web Money Z104136428007 R346491122688
* @package topic description
*/
-->
<extension engine="1.0">
    <id>topic_desc</id>
    <title>topic description</title>
    <version>0.5.0</version>
    <description>Topic Description</description>
    <author>KANekT</author>
    <minversion>1.3.4</minversion>
    <maxtestedon>1.3.4</maxtestedon>
    <install>
        <![CDATA[
                $forum_db->add_field('topics', 'topic_desc', 'varchar(255)', true);
                $query = array(
                   'INSERT'  => 'conf_name, conf_value',
                   'INTO'    => 'config',
                   'VALUES'  => '\'o_topic_desc\', \'0\''
                );
                $forum_db->query_build($query);
        ]]>
    </install>
    <uninstall>
        <![CDATA[
            $forum_db->drop_field('topics', 'topic_desc');
            $query = array(
                'DELETE'     => 'config',
                'WHERE'        => 'conf_name in (\'o_topic_desc\')',
            );
            $forum_db->query_build($query);
        ]]>
    </uninstall>
    <hooks>
        <hook id="po_pre_post_contents" priority = "2">
            <![CDATA[
            if ($fid)
            {
                if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
                    require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
                else
                    require $ext_info['path'].'/lang/English.php';
                ?>
                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="sf-box text required longtext">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_topic['Topic Description']; ?></span></label><br />
                            <span class="fld-input"><input id="fld<?php echo $forum_page['fld_count'] ?>" type="text" name="topic_desc" value="<?php echo empty($_POST['topic_desc']) ? '' : forum_htmlencode($_POST['topic_desc']) ?>" size="80" maxlength="100"/></span>
                    </div>
                </div>
            <?php
            }
            ]]>
        </hook>
        <hook id="po_end_validation, mr_confirm_split_posts_form_submitted"><![CDATA[
            if (!empty($_POST['topic_desc']))
                $new_desc = utf8_trim($_POST['topic_desc']);
        ]]></hook>
        <hook id="po_pre_add_topic"><![CDATA[
        if(isset($new_desc)) $post_info['topic_desc'] = $new_desc;
        ]]></hook>       
        <hook id="fn_add_topic_qr_add_topic"><![CDATA[
            if (!empty($post_info['topic_desc']))
            {
                $query['INSERT'] .= ', topic_desc';
                $query['VALUES'] .= ', \''.$forum_db->escape($post_info['topic_desc']).'\'';
            }
        ]]></hook>       
        <hook id="ed_pre_message_box" priority = "2"><![CDATA[
                if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
                    require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
                else
                    require $ext_info['path'].'/lang/English.php';
                   
            if ($can_edit_subject && (FORUM_PAGE != 'ajax_post_edit')):
            $top = forum_htmlencode(isset($_POST['topic_desc']) ? $_POST['topic_desc'] : $cur_post['topic_desc']);           
            ?>
                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                    <div class="sf-box text required longtext">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_topic['Topic Description']; ?></span></label><br />
                            <span class="fld-input"><input id="fld<?php echo $forum_page['fld_count'] ?>" type="text" name="topic_desc" value="<?php echo $top ?>" size="80" maxlength="100"/></span>
                    </div>
                </div>
            <?php
            endif;
        ]]></hook>
        <hook id="ed_qr_update_subject"><![CDATA[
            $topic_desc = forum_trim($_POST['topic_desc']);
            $query['SET'] .= ', topic_desc=\''.$forum_db->escape($topic_desc).'\'';
        ]]></hook>
        <hook id="vf_qr_get_topics, ed_qr_get_post_info"><![CDATA[
                $query['SELECT'] .= ', t.topic_desc';
        ]]></hook>
        <hook id="vf_row_pre_item_subject_merge"><![CDATA[
        if (!empty($cur_topic['topic_desc']))
        {
            if ($forum_config['o_topic_desc'] != '0')
            {
                $forum_page['item_body']['subject']['topic_desc'] = '<p><small>'.forum_htmlencode($cur_topic['topic_desc']).'</small></p>';
            }
        }
        ]]></hook>
        <hook id="vf_topic_loop_normal_topic_pre_item_title_merge"><![CDATA[
        if (!empty($cur_topic['topic_desc']))
        {
            if ($forum_config['o_topic_desc'] != '1' )
            {
                $forum_page['item_title']['link'] = '<a href="'.forum_link($forum_url['topic'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))).'" alt="'.$cur_topic['topic_desc'].'" title="'.$cur_topic['topic_desc'].'">'.forum_htmlencode($cur_topic['subject']).'</a>';

            }
        }
        ]]></hook>
        <hook id="ape_start"><![CDATA[
            define('FORUM_PAGE', 'ajax_post_edit');
        ]]></hook>
        <hook id="aop_features_validation"><![CDATA[
if (!isset($form['topic_desc'])) $form['topic_desc'] = '0';
        ]]></hook>
       
        <hook id="aop_features_message_fieldset_end"><![CDATA[
    if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
        require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
    else
        require $ext_info['path'].'/lang/English.php';

        // Reset counter
    $forum_page['group_count'] = $forum_page['item_count'] = 0;
?>
            <div class="content-head">
                <h2 class="hn"><span><?php echo $lang_topic['Topic features head'] ?></span></h2>
            </div>
            <fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
                <legend class="group-legend"><span><?php echo $lang_topic['Topic legend'] ?></span></legend>
                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
                        <div class="mf-box">
                            <div class="mf-item">
                                <span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[topic_desc]" value="0"<?php if ($forum_config['o_topic_desc'] == '0') echo ' checked="checked"' ?> /></span>
                                <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_topic['Topic enable'] ?></label>
                            </div>
                            <div class="mf-item">
                                <span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[topic_desc]" value="1"<?php if ($forum_config['o_topic_desc'] == '1') echo ' checked="checked"' ?> /></span>
                                <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_topic['Topic enable mouse'] ?></label>
                            </div>
                            <div class="mf-item">
                                <span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="form[topic_desc]" value="2"<?php if ($forum_config['o_topic_desc'] == '2') echo ' checked="checked"' ?> /></span>
                                <label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_topic['Topic enable and mouse'] ?></label>
                            </div>
                        </div>
                </div>
            </fieldset>
<?php       
               
        ]]></hook>    </hooks>
</extension>

[/code]