PDA

View Full Version : Custom Attachment Field in NewPost and Display as Preview next to thread in Forum


asdfadrian
05-16-2011, 11:54 PM
I currently have made custom modified ForumDisplay.php and newthread.php

What I am asking how do I include a separate "Browse from computer" attachment input field into my newthread.php when a user is creating a thread like in the image below?

Here is my current Newthread.php. Boxed is the area I want to edit.
https://vborg.vbsupport.ru/attachment.php?attachmentid=129151&stc=1&d=1304240824

In place for the red box in the image displayed above I want to replace with the red box (the <Input> Fields with the Browse button) in the image below
https://vborg.vbsupport.ru/attachment.php?attachmentid=129152&stc=1&d=1304240824

Secondly how can I use the image in the custom attachment attached and display that as the image preview next to the forum thread title when browsing a forum? I want to achieve something that looks like this:
https://vborg.vbsupport.ru/attachment.php?attachmentid=129150&stc=1&d=1304240824

asdfadrian
05-18-2011, 09:00 PM
Does anyone know?

--------------- Added 1305760943 at 1305760943 ---------------

At least someone tell me how to embed the newattachment.php above the tags when posting a new thread.

--------------- Added 1305762737 at 1305762737 ---------------

Below is the current PostNewThread bit that I have made along with the hook, however it doesnt show up properly stilll..

I know that the hooks for attachments being used in the attachment.php are as follows:
newattachment_attachsum
newattachment_complete
newattachment_start

However I do not know how to "include" the attachment variables into the newthread_form_complete hook below. How would I approach this problem?

Here is the plugin using the newthread_form_complete hook:
eval('$uploadresource_icons = "' . fetch_template('uploadresource_icons') . '";');

Here is the modified post_newthread bit
[PHP]$postpreview

<form action="newthread.php?do=postthread&amp;f=$forumid" method="post" name="vbform"<if condition="!is_browser('webtv')"> onsubmit="return vB_Editor['$editorid'].prepare_submit(this.subject.value, $vboptions[postminchars])"</if>>

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">
<span class="smallfont" style="float:$stylevar[right]"><strong>Resource Type</strong>: <a href="forumdisplay.php?$session[sessionurl]f=$foruminfo[forumid]">$foruminfo[title]</a></span>
Upload Icon
</td>
</tr>
<tr>
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]" align="$stylevar[left]">

$human_verify

<!-- subject field -->
<table cellpadding="0" cellspacing="0" border="0" class="fieldset">
<tr>
<if condition="$prefix_options">
<td class="smallfont">$vbphrase[prefix]:</td>
<td class="smallfont" colspan="3">$vbphrase[title]:</td>
<else />
<td class="smallfont" colspan="4">$vbphrase[title]:</td>
</if>
</tr>
<tr>
<if condition="$prefix_options">
<td style="padding-right: 1px">
<select name="prefixid" class="bginput">
<option value="">$vbphrase[no_prefix_meta]</option>
$prefix_options
</select>
</td>
</if>
<td>
<input type="text" class="bginput" name="subject" value="$subject" size="40" maxlength="$vboptions[titlemaxchars]" tabindex="1" />
</td>
<td>&nbsp; by $bbuserinfo[username]&nbsp;</td>
<td><img id="display_posticon" src="$selectedicon[src]" alt="$selectedicon[alt]" /></td>
</tr>
</table>
<!-- / subject field -->

<!-- message area -->
<div class="smallfont">Resource Description:</div>
$messagearea
<!-- / message area -->

<!-- attachment area -->
$attachmentoption
<!-- / attachment area -->


<fieldset class="fieldset">
<legend>Upload Screenshot: </legend>

<if condition="$show['attachoption']">
<if condition="$show['attachfile']">
$vbphrase[upload_file_from_your_computer]
<table cellpadding="0" cellspacing="$stylevar[formspacer]" width="100%" border="0">
<tr valign="bottom">
<td>
<input type="hidden" name="MAX_FILE_SIZE" value="$inimaxattach" />
$attachinput
</td>
<td align="$stylevar[right]"><input type="submit" class="button" name="upload" value="$vbphrase[upload]" style="width:70px" onclick="return verify_upload(this.form);" /></td>
</tr>
</table>
</if>
</if>
</fieldset>

<if condition="$show['tag_option']">
<fieldset class="fieldset" style="margin-top: $stylevar[cellpadding]px">
<legend>Resource Keywords / Tags</legend>
<div style="padding:$stylevar[formspacer]px">
<div>Input in the field below as many keywords/tags describing your resource. <br>
$vbphrase[separate_tags_using_comma]</div>
<span id="tag_add"><input type="text" class="bginput" name="taglist" id="tag_add_input" value="$newpost[taglist]" size="50" tabindex="1" />
</span>
<if condition="$show['tags_remain']"><div><phrase 1="$tags_remain">$vbphrase[you_may_add_x_tags_to_thread]</phrase>
</div></if>

</div>


<if condition="$show['popups']">
<div id="tag_add_menu" class="vbmenu_popup" style="display:none"></div>
<script type="text/javascript" src="clientscript/vbulletin_ajax_tagsugg.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript">
<!--
vbmenu_register('tag_add', true);
tag_add_comp = new vB_AJAX_TagSuggest('tag_add_comp', 'tag_add_input', 'tag_add');
tag_add_comp.allow_multiple = true;
tag_add_comp.set_delimiters('$tag_delimiters');
//-->
</script>
</if>
</fieldset>
</if>

<if condition="$show['member']">
<fieldset class="fieldset">
<legend>Resource Subscription</legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
<tr>
<td>$vbphrase[notification_type]:<br /><select name="emailupdate" tabindex="1">
<option value="9999" $emailchecked[9999]>$vbphrase[do_not_subscribe]</option>
<option value="0" $emailchecked[0]>$vbphrase[no_email_notification]</option>
<option value="1" $emailchecked[1]>$vbphrase[instant_email_notification]</option>
<option value="2" $emailchecked[2]>$vbphrase[daily_email_notification]</option>

</select></td>
<if condition="$show['subscribefolders']"><td>$vbphrase[folder]:<br /><select name="folderid" tabindex="1">$folderbits</select></td></if>
</tr>
</table>
</fieldset>

</if>


</div>
</div>

<div style="margin-top:$stylevar[cellpadding]px">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="f" value="$forumid" />
<input type="hidden" name="do" value="postthread" />
<input type="hidden" name="posthash" value="$posthash" />
<input type="hidden" name="poststarttime" value="$poststarttime" />
<input type="hidden" name="loggedinuser" value="$bbuserinfo[userid]" />
<input type="submit" class="button" name="sbutton" id="{$editorid}_save" value="Upload Resource" accesskey="s" tabindex="1" />
<input type="submit" class="button" name="preview" value="$vbphrase[preview_post]" accesskey="r" tabindex="1" />
</div>
</td>
</tr>
</table>


<if condition="$show['additional_options']">
<br />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('newpost_options')"><img id="collapseimg_newpost_options" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_newpost_options].gif" alt="" border="0" /></a>
Submission Rules: </td>
</tr>
</thead>
<tbody id="collapseobj_newpost_options" style="$vbcollapse[collapseobj_newpost_options]">
<tr valign="top">
<td class="panelsurround" align="center">
<div class="panel">
<div style="width:$stylevar[formwidth]" align="$stylevar[left]">

<if condition="$show['podcasturl']">
<!-- podcast stuff -->
<fieldset class="fieldset">
<legend></legend>
</fieldset>
<!-- / podcast stuff -->
</if>

<if condition="$show['misc_options']">
<fieldset ><legend></legend>
<legend><h3>Rule Number 1: No Copy and Paste</h3></legend>
We do not accept any copy and paste images. All images must be the uploader's created content.
<legend><h3>Rule Number 2: Author's Consent</h3></legend>
Please do not edit any material that is not yours without the authors permission. Consent from the owner of the material must be approved before uploading.
</fieldset>
</if>
</div>
</div>

<div style="margin-top:$stylevar[cellpadding]px">
<input type="submit" class="button" name="sbutton" value="$vbphrase[submit_new_thread]" accesskey="s" tabindex="1" />
<input type="submit" class="button" name="preview" value="$vbphrase[preview_post]" accesskey="r" tabindex="1" />
</div>
</td>
</tr>
</tbody>
</table>
</if>

</form>

<br />

--------------- Added 1305764832 at 1305764832 ---------------

Update:

Using the hook newattachment_complete:
eval('$inlineattachment = "' . fetch_template('inclineattachment') . '";');

I have modified the newattachment style bit and added it to my own custom "inlineattachment" template below:
<script type="text/javascript">
<!--

function verify_upload(formobj)
{
var haveupload = false;
for (var i=0; i < formobj.elements.length; i++)
{
var elm = formobj.elements[i];
if (elm.type == 'file' || elm.type == 'text')
{
if (elm.value != "")
{
haveupload = true;
}
}
}

if (haveupload)
{
obj = fetch_object("uploading");
obj.style.display = "";
return true;
}
else
{
alert("$vbphrase[select_a_file_to_attach]");
return false;
}
}

<if condition="$show['updateparent']">
if (typeof window.opener.vB_Attachments != 'undefined')
{
window.opener.vB_Attachments.reset();
$new_attachlist_js
}
</if>

//-->
</script>

<form enctype="multipart/form-data" action="newattachment.php?do=manageattach&amp;p=$postid" name="newattachment" method="post">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="do" value="manageattach" />
<input type="hidden" name="t" value="$threadid" />
<input type="hidden" name="f" value="$forumid" />
<input type="hidden" name="p" value="$postid" />
<input type="hidden" name="poststarttime" value="$poststarttime" />
<input type="hidden" name="editpost" value="$editpost" />
<input type="hidden" name="posthash" value="$posthash" />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%">
<if condition="$show['errors']">
<tr>
<td class="thead">$vbphrase[upload_errors]</td>
</tr>
$errorlist
</if>
<tr>
<input type="hidden" name="MAX_FILE_SIZE" value="$inimaxattach" />
$attachinput
</td>
<td align="$stylevar[right]"><input type="submit" class="button" name="upload" value="$vbphrase[upload]" style="width:70px" onClick="return verify_upload(this.form);" />
</td>
</tr>
</table>

</form>


Still nothing.. Someone please help me.

--------------- Added 1305785670 at 1305785670 ---------------

Bump.

asdfadrian
05-20-2011, 02:38 AM
Uhmmmm, anyone? Please help me!