MyBB Hacks

Full Version: Xthread modification?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm currently trying to add something to my downloads section by modifying the html. I'm trying to add an option to the file upload option.

ex. radio1 radio2 radio3
radio1 gives me file upload
radio2 gives me url upload
radio3 gives me url link

I've changed the javascript to:

Code:
<script type="text/javascript"><!--
			      $("xtasel_fupload").style.display="";
$("xtaseltext_file_fupload").style.display=$("xtaseltext_url_fupload").style.display=$("xthreads_dld_directfile").style.display="none";
			($("xtaselopt_file_fupload").onclick = $("xtaselopt_url_fupload").onclick = $("xtaselopt_dld_directfile").onclick = function() {
				var f=$("xtaselopt_file_fupload").checked ? 0 : ($("xtaselopt_url_fupload").checked ? 1 : 2);
							$("xthreads_fupload").style.display = (!f?"":"none");
							$("xtaurl_fupload").style.display = (f==1?"":"none");
							$("xthreads_dld_directfile").style.display = (f==2?"":"none");
							if(!f) $("xthreads_fupload").value = "";
						})();
					
					//-->
					</script>


Which works rather well when determining the option box to put up. Everything works well except for the direct dl section.

Here's my newthread html

Code:
<html>
<head>
<title>{$lang->newthread_in}</title>
{$headerinclude}
<script type="text/javascript" src="jscripts/post.js?ver=1400"></script>
</head>
<body>
{$header}
{$preview}
{$thread_errors}
{$attacherror}
<form action="newthread.php?fid={$fid}&amp;processed=1" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->post_new_thread}</strong></td>
</tr>
{$loginbox}
<tr>
<td class="trow2" width="20%"><strong>{$lang->thread_subject}</strong></td>
<td class="trow2">{$prefixselect}<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
<!-- start: threadfields_inputrow -->
<td class="trow1" width="20%"><strong>File Upload</strong></td>

<td class="trow1">
<div id="xtarow_fupsss">
<div style="display: none; font-size: x-small;" id="xtasel_fupsss">
<label style="margin: 0 0.6em;">
<input type="radio" name="xtasel_fupsss" value="file" checked="checked" id="xtaselopt_file_fupsss"/>Upload File</label>
<label style="margin: 0 0.6em;">
<input type="radio" name="xtasel_fupsss" value="url" id="xtaselopt_url_fupsss"/>Upload From URL</label>
<label style="margin: 0 0.6em;">
<input type="radio" name="xtasel_fupsss" value="url" id="xtaselopt_dld_directfile"/>Direct Download</label></div>

<div><span id="xtaseltext_file_fupsss">File: </span>
<input type="hidden" name="MAX_FILE_SIZE" value="603979776"/>
<input type="file" class="fileupload" name="xthreads_fupsss" size="40" tabindex="2" id="xthreads_fupsss"/>
<input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>

<div><span id="xtaseltext_url_fupsss">URL: </span>
<input type="text" class="textbox" id="xtaurl_fupsss" name="xtaurl_fupsss" size="40" value="http://"/></div>

<div><input type="text" class="textbox" id="xthreads_dld_directfile" name="xthreads_dld_directfile" size="40" tabindex="3" value=""/></div></div>

                        <script type="text/javascript"><!--
			      $("xtasel_fupsss").style.display="";
$("xtaseltext_file_fupsss").style.display=$("xtaseltext_url_fupsss").style.display=$("xthreads_dld_directfile").style.display="none";
			($("xtaselopt_file_fupsss").onclick = $("xtaselopt_url_fupsss").onclick = $("xtaselopt_dld_directfile").onclick = function() {
				var f=$("xtaselopt_file_fupsss").checked ? 0 : ($("xtaselopt_url_fupsss").checked ? 1 : 2);
							$("xthreads_fupsss").style.display = (!f?"":"none");
							$("xtaurl_fupsss").style.display = (f==1?"":"none");
							$("xthreads_dld_directfile").style.display = (f==2?"":"none");
							if(!f) $("xthreads_fupsss").value = "";
						})();
					
					//-->
					</script>
					
<small style="display: block;">Upload a file. You can choose to upload from your computer or from a URL. You can also choose to use a direct download link.</small></td>
</tr>

<tr>
<td class="trow1" width="20%"><strong>Author</strong></td>
<td class="trow1"><input type="text" class="textbox" name="xthreads_dlauth" size="50" tabindex="4" value=""/><small style="display: block;">Credit the person who made the item you are uploading.</small></td>
</tr>
  
<tr>
<td class="trow2" width="20%"><strong>Image</strong></td>
<td class="trow2"><div id="xtarow_fscr"><div style="display: none; font-size: x-small;" id="xtasel_fscr"><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr" value="file" checked="checked" id="xtaselopt_file_fscr"/>File</label><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr" value="url" id="xtaselopt_url_fscr"/>URL</label></div>
<div><span id="xtaseltext_file_fscr">File: </span><input type="hidden" name="MAX_FILE_SIZE" value="1048576"/><input type="file" class="fileupload" name="xthreads_fscr" size="40" tabindex="5" id="xthreads_fscr"/><input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>
<div><span id="xtaseltext_url_fscr">URL: </span><input type="text" class="textbox" id="xtaurl_fscr" name="xtaurl_fscr" size="40" value="http://"/></div></div><script type="text/javascript"><!--
					
						$("xtasel_fscr").style.display="";
						$("xtaseltext_file_fscr").style.display=$("xtaseltext_url_fscr").style.display="none";
						($("xtaselopt_file_fscr").onclick = $("xtaselopt_url_fscr").onclick = function() {
							var f=$("xtaselopt_file_fscr").checked;
							$("xthreads_fscr").style.display = (f?"":"none");
							$("xtaurl_fscr").style.display = (f?"none":"");
							if(!f) $("xthreads_fscr").value = "";
						})();
					
					//-->
					</script><small style="display: block;"></small></td>
</tr>
  
<tr>
<td class="trow1" width="20%"><strong>Category</strong></td>
<td class="trow1"><select name="xthreads_fcatsss" size="1" style="width: 20em;" tabindex="18"><option value="Characters">Characters</option><option value="Stages">Stages</option><option value="Misc">Misc</option></select><small style="display: block;"></small></td>
</tr>
  
<tr>
<td class="trow2" width="20%"><strong>Description</strong></td>
<td class="trow2"><textarea name="xthreads_fdesc" maxlength="255" rows="5" cols="40" tabindex="7"></textarea><br/><script type="text/javascript" src="http://cavernofcreativity.com/Atlas/inc/plugins/automedia/automedia.js"></script>
<a id="amoff" href="javascript:void(0);"><img src="inc/plugins/automedia/amoff.png" width="29" height="25" alt="Disable AutoMedia embedding for this link." title="Disable AutoMedia embedding for this link."/></a>&nbsp;&nbsp;
<a id="ampl" href="javascript:void(0);"><img src="inc/plugins/automedia/ampl.png" width="29" height="25" alt="AutoMedia MP3 Playlist" title="AutoMedia MP3 Playlist"/></a><br/><br/><small style="display: block;"></small></td>
</tr>
  
<tr>
<td class="trow1" width="20%"><strong>Additional Image 1</strong></td>
<td class="trow1"><div id="xtarow_fscr2"><div style="display: none; font-size: x-small;" id="xtasel_fscr2"><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr2" value="file" checked="checked" id="xtaselopt_file_fscr2"/>File</label><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr2" value="url" id="xtaselopt_url_fscr2"/>URL</label></div>
<div><span id="xtaseltext_file_fscr2">File: </span><input type="hidden" name="MAX_FILE_SIZE" value="10048576"/><input type="file" class="fileupload" name="xthreads_fscr2" size="40" tabindex="8" id="xthreads_fscr2"/><input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>
<div><span id="xtaseltext_url_fscr2">URL: </span><input type="text" class="textbox" id="xtaurl_fscr2" name="xtaurl_fscr2" size="40" value="http://"/></div></div><script type="text/javascript"><!--
					
						$("xtasel_fscr2").style.display="";
						$("xtaseltext_file_fscr2").style.display=$("xtaseltext_url_fscr2").style.display="none";
						($("xtaselopt_file_fscr2").onclick = $("xtaselopt_url_fscr2").onclick = function() {
							var f=$("xtaselopt_file_fscr2").checked;
							$("xthreads_fscr2").style.display = (f?"":"none");
							$("xtaurl_fscr2").style.display = (f?"none":"");
							if(!f) $("xthreads_fscr2").value = "";
						})();
					
					//-->
					</script><small style="display: block;">Upload an additional image - Not required</small></td>
</tr>
  
<tr>
<td class="trow2" width="20%"><strong>Additional Image 2</strong></td>
<td class="trow2"><div id="xtarow_fscr3"><div style="display: none; font-size: x-small;" id="xtasel_fscr3"><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr3" value="file" checked="checked" id="xtaselopt_file_fscr3"/>File</label><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr3" value="url" id="xtaselopt_url_fscr3"/>URL</label></div>
<div><span id="xtaseltext_file_fscr3">File: </span><input type="hidden" name="MAX_FILE_SIZE" value="10048576"/><input type="file" class="fileupload" name="xthreads_fscr3" size="40" tabindex="9" id="xthreads_fscr3"/><input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>
<div><span id="xtaseltext_url_fscr3">URL: </span><input type="text" class="textbox" id="xtaurl_fscr3" name="xtaurl_fscr3" size="40" value="http://"/></div></div><script type="text/javascript"><!--
					
						$("xtasel_fscr3").style.display="";
						$("xtaseltext_file_fscr3").style.display=$("xtaseltext_url_fscr3").style.display="none";
						($("xtaselopt_file_fscr3").onclick = $("xtaselopt_url_fscr3").onclick = function() {
							var f=$("xtaselopt_file_fscr3").checked;
							$("xthreads_fscr3").style.display = (f?"":"none");
							$("xtaurl_fscr3").style.display = (f?"none":"");
							if(!f) $("xthreads_fscr3").value = "";
						})();
					
					//-->
					</script><small style="display: block;">Upload an additional image - Not required</small></td>
</tr>
  
<tr>
<td class="trow1" width="20%"><strong>Additional Image 3</strong></td>
<td class="trow1"><div id="xtarow_fscr4"><div style="display: none; font-size: x-small;" id="xtasel_fscr4"><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr4" value="file" checked="checked" id="xtaselopt_file_fscr4"/>File</label><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr4" value="url" id="xtaselopt_url_fscr4"/>URL</label></div>
<div><span id="xtaseltext_file_fscr4">File: </span><input type="hidden" name="MAX_FILE_SIZE" value="10048576"/><input type="file" class="fileupload" name="xthreads_fscr4" size="40" tabindex="10" id="xthreads_fscr4"/><input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>
<div><span id="xtaseltext_url_fscr4">URL: </span><input type="text" class="textbox" id="xtaurl_fscr4" name="xtaurl_fscr4" size="40" value="http://"/></div></div><script type="text/javascript"><!--
					
						$("xtasel_fscr4").style.display="";
						$("xtaseltext_file_fscr4").style.display=$("xtaseltext_url_fscr4").style.display="none";
						($("xtaselopt_file_fscr4").onclick = $("xtaselopt_url_fscr4").onclick = function() {
							var f=$("xtaselopt_file_fscr4").checked;
							$("xthreads_fscr4").style.display = (f?"":"none");
							$("xtaurl_fscr4").style.display = (f?"none":"");
							if(!f) $("xthreads_fscr4").value = "";
						})();
					
					//-->
					</script><small style="display: block;">Upload an additional image - Not required</small></td>
</tr>
  
<tr>
<td class="trow2" width="20%"><strong>Additional Image 4</strong></td>
<td class="trow2"><div id="xtarow_fscr5"><div style="display: none; font-size: x-small;" id="xtasel_fscr5"><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr5" value="file" checked="checked" id="xtaselopt_file_fscr5"/>File</label><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr5" value="url" id="xtaselopt_url_fscr5"/>URL</label></div>
<div><span id="xtaseltext_file_fscr5">File: </span><input type="hidden" name="MAX_FILE_SIZE" value="10048576"/><input type="file" class="fileupload" name="xthreads_fscr5" size="40" tabindex="11" id="xthreads_fscr5"/><input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>
<div><span id="xtaseltext_url_fscr5">URL: </span><input type="text" class="textbox" id="xtaurl_fscr5" name="xtaurl_fscr5" size="40" value="http://"/></div></div><script type="text/javascript"><!--
					
						$("xtasel_fscr5").style.display="";
						$("xtaseltext_file_fscr5").style.display=$("xtaseltext_url_fscr5").style.display="none";
						($("xtaselopt_file_fscr5").onclick = $("xtaselopt_url_fscr5").onclick = function() {
							var f=$("xtaselopt_file_fscr5").checked;
							$("xthreads_fscr5").style.display = (f?"":"none");
							$("xtaurl_fscr5").style.display = (f?"none":"");
							if(!f) $("xthreads_fscr5").value = "";
						})();
					
					//-->
					</script><small style="display: block;">Upload an additional image - Not required</small></td>
</tr>
  
<tr>
<td class="trow1" width="20%"><strong>Additional Image 5</strong></td>
<td class="trow1"><div id="xtarow_fscr6"><div style="display: none; font-size: x-small;" id="xtasel_fscr6"><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr6" value="file" checked="checked" id="xtaselopt_file_fscr6"/>File</label><label style="margin: 0 0.6em;"><input type="radio" name="xtasel_fscr6" value="url" id="xtaselopt_url_fscr6"/>URL</label></div>
<div><span id="xtaseltext_file_fscr6">File: </span><input type="hidden" name="MAX_FILE_SIZE" value="10048576"/><input type="file" class="fileupload" name="xthreads_fscr6" size="40" tabindex="12" id="xthreads_fscr6"/><input type="hidden" name="MAX_FILE_SIZE" value="0"/></div>
<div><span id="xtaseltext_url_fscr6">URL: </span><input type="text" class="textbox" id="xtaurl_fscr6" name="xtaurl_fscr6" size="40" value="http://"/></div></div><script type="text/javascript"><!--
					
						$("xtasel_fscr6").style.display="";
						$("xtaseltext_file_fscr6").style.display=$("xtaseltext_url_fscr6").style.display="none";
						($("xtaselopt_file_fscr6").onclick = $("xtaselopt_url_fscr6").onclick = function() {
							var f=$("xtaselopt_file_fscr6").checked;
							$("xthreads_fscr6").style.display = (f?"":"none");
							$("xtaurl_fscr6").style.display = (f?"none":"");
							if(!f) $("xthreads_fscr6").value = "";
						})();
					
					//-->
					</script><small style="display: block;">Upload an additional picture - Not required</small></td>
</tr>
<!-- end: threadfields_inputrow -->
{$posticons}
<tr>
<td class="trow2" valign="top"><strong>{$lang->your_message}</strong>{$smilieinserter}</td>
<td class="trow2">
<textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea>
{$codebuttons}
{$multiquote_external}
</td>
</tr>
<tr>
<td class="trow1" valign="top"><strong>{$lang->post_options}</strong></td>
<td class="trow1"><span class="smalltext">
<label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="7"{$postoptionschecked['signature']} /> {$lang->options_sig}</label>
{$disablesmilies}</span></td>
</tr>
{$modoptions}
{$subscriptionmethod}
{$pollbox}
{$captcha}
</table>
{$attachbox}
<br />
<div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" />{$savedraftbutton}</div>
<input type="hidden" name="action" value="do_newthread" />
<input type="hidden" name="posthash" value="{$posthash}" />
<input type="hidden" name="attachmentaid" value="" />
<input type="hidden" name="attachmentact" value="" />
<input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
<input type="hidden" name="tid" value="{$tid}" />
{$editdraftpid}
</form>
{$forumrules}
{$footer}
</body>
</html>


The problem happens when I click direct download. When I'm done filling out the info and click submit, it prompts me to fill in something for file upload. (even though I filled it out already).
Any help with this would definitely be appreciated.

(04-10-2012 03:51 AM)Yin Wrote: [ -> ]The problem happens when I click direct download. When I'm done filling out the info and click submit, it prompts me to fill in something for file upload. (even though I filled it out already).

I don't know what you mean by "you filled out already".
Reading your code above, it seems that you use two custom thread fields for your file upload.
One File input type (file upload and URL upload), and one Textbox input type (direct link).
Each custom thread fields has their own Editable by / Required Field? setting.
If both of them is a required fields, you can't fill one of them only.
If one of them is a required field, at least you must fill the required field.
For example, if you set the File input type as a required field, and the Textbox as a non required field, and your user fill the Textbox only, they will get the inline errors saying that your File input type need to be filled, because it's a required field.
Thank you for answering. Let me try to clarify what I am trying to say:

When I say I filled it out already I mean that I've already put in a link for the direct download, but not for the file upload.

Yeah, so how would I make it so that if one is filled in, the other is no longer required?
What I did was make the third button another xthreads field (the text box) so that it would just take a link and not upload it.

I'm trying to merge it with the file upload area. So that text box field only shows when the radio button for it is clicked. That part works, but it's just that it does not function

Quote:If both of them is a required fields, you can't fill one of them only.
If one of them is a required field, at least you must fill the required field.

This is essentially what I am trying to bypass. Looking for a way to make it so that if one is selected, the other is no longer required since the other is filled out.

If there's an easier way to do this please let me know. I also have the php in templates/conditions installed if there's a way to do it with that.
You cannot do that without a custom plugin / code modification.
Where in the code can I edit that? There's a lot of xthreads files, and I don't know which one has the html for the file upload choice. I don't mind digging in there, I just a push in the right direction.
You can just make a plugin which checks $mybb->input and validates it, spitting out an error if unsuccessful.
Jap Never made a plug in before. I'll have to ask my buddy leefish about how to go about starting a plug in. Thanks!
Reference URL's