Advertisement:

Make subject field read only in a specific category.

Aloittaja nopresnik, heinäkuu 12, 2013, 03:37:22 IP

« edellinen - seuraava »

nopresnik

Hey guys.

I would like to simply know how I can set the subject box to be read only in just one category. The reason for this is because I have an external system set up that will automatically set a title for the topic by appending ;?subject=TEXT on the end of the new topic URL.  I would not like it for users to change the auto set topic title (don't ask why, please).

So is there a way to hide it, or make it read only in one specific category?

Thanks in advance!

margarett

It's actually very simple, making use of the "readonly" property of "input" ;)

You should go to Post.template.php and find:

// Now show the subject box for this post.
echo '
<dt>
<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
</dt>
<dd>
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
</dd>
<dt class="clear_left">
', $txt['message_icon'], ':
</dt>
<dd>
<select name="icon" id="icon" onchange="showimage()">';

Replace with:

// Now show the subject box for this post.
echo '
<dt>
<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
</dt>
<dd>';
if ($context['current_board']==1)
echo'
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" readonly/>';
else
echo'
<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text"/>';
echo '
</dd>
<dt class="clear_left">
', $txt['message_icon'], ':
</dt>
<dd>
<select name="icon" id="icon" onchange="showimage()">';


On the "if" statement you can adjust your board ID as you wish. You probably need to make it a series of "ORs" if it should affect several boards...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

And passing the subject by url makes actually pretty easy for your users to change it:
;subject=whatever


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: