Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: wengwashere on September 23, 2006, 12:43:02 AM

Title: How do set "Post a redirection topic." unchecked as default?
Post by: wengwashere on September 23, 2006, 12:43:02 AM
any tips would help :D
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: jerm on September 23, 2006, 12:52:45 AM
Admin > Current Theme > Reset Options > Reset all member's current options for this theme
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: codenaught on September 23, 2006, 11:45:10 AM
Quote from: jerm on September 23, 2006, 12:52:45 AM
Admin > Current Theme > Reset Options > Reset all member's current options for this theme
I don't see where the option he is asking for would be there?

Open Themes/default/MoveTopic.template.php

Find:

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" checked="checked" onclick="document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="check" />

Change to:

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" onclick="document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="check" />
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: adp on August 31, 2007, 07:51:13 AM
And now? I think the code is different...
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: codenaught on August 31, 2007, 11:18:44 AM
That same code is there in SMF 1.1.3.
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Ihmeliö on October 28, 2010, 02:55:51 AM
How should I do this in 2.x?
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Aleksi "Lex" Kilpinen on October 29, 2010, 06:38:11 AM
Haven't checked, but most probably very similarly. At least, the same file would still handle this.
Have you checked if the code has changed much?

Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Ihmeliö on November 01, 2010, 07:24:47 PM
There's this:

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" ', $context['is_approved'] ? 'checked="checked"' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>


I tried replacing that with the proposed one, and it worked otherwise but it shows the "Please enter a brief description as to
why this topic is being moved." field by default, which is not good since the option is obviously not even selected.
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: JimM on November 02, 2010, 08:56:28 PM
Try this line in place of the one you posted in reply #7

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" ', $context['is_approved'] ?  : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Ihmeliö on November 02, 2010, 09:13:29 PM
Quote from: JimM on November 02, 2010, 08:56:28 PM
Try this line in place of the one you posted in reply #7
Still same thing. The description box goes away when I first check the "Post a redirection topic" option, and then uncheck it.

The whole MoveTopic template:
<?php
// Version: 2.0 RC3; MoveTopic
// Show an interface for selecting which board to move a post to.
function template_main()
{
  global
$context, $settings, $options, $txt, $scripturl;

  echo
'
  <div id="move_topic" class="lower_padding">
     <form action="'
, $scripturl, '?action=movetopic2;topic=', $context['current_topic'], '.0" method="post" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">
        <div class="cat_bar">
           <h3 class="catbg">'
, $txt['move_topic'], '</h3>
        </div>
        <div class="windowbg centertext">
           <span class="topslice"><span></span></span>
           <div class="content">
              <div class="move_topic">
                 <dl class="settings">
                    <dt>
                       <strong>'
, $txt['move_to'], ':</strong>
                    </dt>
                    <dd>
                       <select name="toboard">'
;

  foreach (
$context['categories'] as $category)
  {
     echo
'
                          <optgroup label="'
, $category['name'], '">';

     foreach (
$category['boards'] as $board)
        echo
'
                             <option value="'
, $board['id'], '"', $board['selected'] ? ' selected="selected"' : '', $board['id'] == $context['current_board'] ? ' disabled="disabled"' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
     echo
'
                          </optgroup>'
;
  }

  echo
'
                       </select>
                    </dd>'
;

 
// Disable the reason textarea when the postRedirect checkbox is unchecked...
 
echo '
                 </dl>
                 <label for="reset_subject"><input type="checkbox" name="reset_subject" id="reset_subject" onclick="document.getElementById(\'subjectArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> '
, $txt['moveTopic2'], '.</label><br />
                 <fieldset id="subjectArea" style="display: none;">
                    <dl class="settings">
                       <dt><strong>'
, $txt['moveTopic3'], ':</strong></dt>
                       <dd><input type="text" name="custom_subject" size="30" value="'
, $context['subject'], '" class="input_text" /></dd>
                    </dl>
                    <label for="enforce_subject"><input type="checkbox" name="enforce_subject" id="enforce_subject" class="input_check" /> '
, $txt['moveTopic4'], '.</label>
                 </fieldset>
                 <label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" '
, $context['is_approved'] ? 'checked="checked"' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>
                 <fieldset id="reasonArea" style="margin-top: 1ex;'
, $context['is_approved'] ? '' : 'display: none;', '">
                    <dl class="settings">
                       <dt>
                          '
, $txt['moved_why'], '
                       </dt>
                       <dd>
                          <textarea name="reason" rows="3" cols="40">'
, $txt['movetopic_default'], '</textarea>
                       </dd>
                    </dl>
                 </fieldset>
                 <div class="righttext">
                    <input type="submit" value="'
, $txt['move_topic'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" />
                 </div>
              </div>
           </div>
           <span class="botslice"><span></span></span>
        </div>'
;

  if (
$context['back_to_topic'])
     echo
'
        <input type="hidden" name="goback" value="1" />'
;

  echo
'
        <input type="hidden" name="'
, $context['session_var'], '" value="', $context['session_id'], '" />
        <input type="hidden" name="seqnum" value="'
, $context['form_sequence_number'], '" />
     </form>
  </div>'
;
}

?>
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Aleksi "Lex" Kilpinen on November 16, 2010, 01:46:53 AM
Hi Ihmeliö, sorry we disappeared on you - but have you had any luck with that since your last post?

I'll move this over to coding discussions, where I think this may get better responses ;)
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: ups on November 16, 2010, 04:25:36 PM
Quote from: JimM on November 02, 2010, 08:56:28 PM
Try this line in place of the one you posted in reply #7

JimM suggestion should work.

Where you have

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" ', $context['is_approved'] ? 'checked="checked"' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>


You should replace with


<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>

Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Ihmeliö on November 17, 2010, 06:38:10 AM
Quote from: ups on November 16, 2010, 04:25:36 PM
Quote from: JimM on November 02, 2010, 08:56:28 PM
Try this line in place of the one you posted in reply #7

JimM suggestion should work.

Where you have

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" ', $context['is_approved'] ? 'checked="checked"' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>


You should replace with


<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>

Ah, hmm. For some reason it doesn's save that particular change when I press "Save changes". I tried adding a comment line into the file, and that one does save, but changing the above mentioned code always reverts back...
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Aleksi "Lex" Kilpinen on November 17, 2010, 06:39:52 AM
That's strange, how you tried editing the file directly with something like Notepad++ ?
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Ihmeliö on November 17, 2010, 06:44:41 AM
Quote from: LexArma on November 17, 2010, 06:39:52 AM
That's strange, how you tried editing the file directly with something like Notepad++ ?
No. I tried now though, and it partly works. Still got this problem:

Quote from: Ihmeliö on November 01, 2010, 07:24:47 PM
I tried replacing that with the proposed one, and it worked otherwise but it shows the "Please enter a brief description as to
why this topic is being moved." field by default, which is not good since the option is obviously not even selected.
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: ups on November 17, 2010, 08:52:27 AM
It seems that these controls are controlled of the $context['is_approved'] variable. A bit unrelated if you ask me. It should be and independent one.

Anyway: you also have to hide the reason textbox by default.

<fieldset id="reasonArea" style="margin-top: 1ex;', $context['is_approved'] ? '' : 'display: none;', '">

to

<fieldset id="reasonArea" style="margin-top: 1ex;  display: none;">


Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Ihmeliö on November 17, 2010, 08:58:26 AM
Ok, that works. Tough I'm still interested in why can't I apply the change directly through the forum software.

edit: If I wanted to completely remove the redirection option, how would I do that?
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: ups on November 17, 2010, 10:01:44 AM
That is just probably an option that the SMF team made. A MOD can be created to enable or disable the redirect in the control panel.

One possible fix is simply to remove the redirect checkbox from the template by removing:

<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>
<fieldset id="reasonArea" style="margin-top: 1ex;  display: none;">
<dl class="settings">
<dt>
', $txt['moved_why'], '
</dt>
<dd>
<textarea name="reason" rows="3" cols="40">', $txt['movetopic_default'], '</textarea>
</dd>
</dl>
</fieldset>


This way, a new redirect cannot be set without some hacking.
To completely remove the feature, more code would have to be changed.

Another option that I consider a bit more elegant is to disable the checkbox by using the "disabled" keyword

<label for="postRedirect"><input disabled type="checkbox" name="postRedirect" id="postRedirect" onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>


Is just a matter of how strongly you want to disable the redirects...
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: Nvb on March 10, 2012, 11:35:11 AM
In 2.0 RC5 i found the following solution

If you only want to remove only the checkbox you need to remove the checkbox checked command:
$context['is_approved'] ? 'checked="checked"' : '', ' onclick="',

So in the Themes/Default/MoveTopictemplate.php change line 53:
from
<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" ',$context['is_approved'] ? 'checked="checked"' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>


Into this:
<label for="postRedirect"><input type="checkbox" name="postRedirect" id="postRedirect" ',$context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt['move_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';" class="input_check" /> ', $txt['moveTopic1'], '.</label>


Everything else works like it should be, this just removes the default "checked" status.
Title: Re: How do set "Post a redirection topic." unchecked as default?
Post by: FishingManMatt on October 09, 2017, 04:52:04 PM
Many thanks guys for posting your solutions. One of my mods constantly forgets to uncheck this option while moving topics.
IMO the most elegant way would be to make the CheckBox unchecked with no TextArea. But.. it the user clicks and checks the CheckBox the reason TextArea should appear.
I'm not so advanced in PHP so for the time being will use the Nvb's solution since it doesn't require too many changes.