I am trying out using the multiple file inputs on my forum. I have set the field up in my Custom Thread Fields, and all is working well except the Display Item Format.
My settings:
Display Format = {VALUE}
Multiple Value Delimiter =
Display Item Format
Code:
<form action="{URL}" method="get">
<button type="submit" class="altbutton icon-download icon-large">CLICK TO DOWNLOAD FILE</button>
</form>
<span class="smalltext"><strong>Filesize </strong><em>{$GLOBALS['threadfields_x']['mupload']['items'][index]['filesize_friendly']}</em> |
<strong>File Name </strong><em>{$GLOBALS['threadfields_x']['mupload']['items'][index]['filename']}</em> | <strong># of Downloads </strong><em>{$GLOBALS['threadfields']['mupload']['items'][index]['downloads_friendly']}</em>
<if ($GLOBALS['threadfields_x']['mupload']['items'][index]['update_date']) == ($GLOBALS['threadfields_x']['mupload']['items'][index]['upload_date']) then> </span><else>
<br />
<strong>File Updated </strong><em>{$GLOBALS['threadfields_x']['mupload']['items'][index]['update_date']}</em></span></if>
<hr>
|
What I am trying to do is output the values for each of the files; I cannot figure out the value I need to use for index.
This is my current output: http://www.leefish.nl/mybb/showthread.php?tid=5649
Please can you advise how I can access the index for each of the files?
For display formats, you don't need to use $threadfields_x etc, {FILESIZE_FRIENDLY} {UPLOAD_DATE} etc should work, for example.
I did try that - but the file information is still not showing.
In the custom thread fields when we input a file then there is a list of the formats we can access and it says:
Quote:For file inputs accepting multiple values, the above only exists in an array as {$GLOBALS['threadfields_x']['key']['items'][index]['item']}, where index is 0 for the 1st attachment, 1 for the 2nd etc. The value can also be accessed through {$GLOBALS['threadfields_x']['key']['value'][index]}. For {$GLOBALS['threadfields']['key']['item']}, item can be one of the following:
num_files - number of files uploaded
num_files_friendly - as above, but number is formatted (eg 1,234 vs 1234)
total_downloads - sum of download counts
total_downloads_friendly - as above, but number is formatted (eg 1,234 vs 1234)
total_filesize - sum of file sizes, in bytes
total_filesize_friendly - as above, but formatted (eg 1.5MB vs 1572864)
upload_time - time when latest file was uploaded
upload_date - date when latest file was uploaded
value - if no file is uploaded, will be Blank Value (see below), otherwise, will be Display Item Format, joined together with Multiple Value Delimiter, then formatted by Display Format
So the characteristics I am trying to access are not available for multiple uploads without an index.
Just to test, I replaced the word index with a number - and of course that sent out the same data for each file (as I expected) - but it did return a value for the filename etc. What I cannot figure out is how to access that index number dynamically.
That section is referring to template variables, as opposed to what you can do in the display format field.
I don't believe the current index is actually exposed anywhere...
{URL} is obviously working for you, so I don't get why {FILESIZE_FRIENDLY} doesn't.
You sure this doesn't work?
HTML Code
<form action="{URL}" method="get">
<button type="submit" class="altbutton icon-download icon-large">CLICK TO DOWNLOAD FILE</button>
</form>
<span class="smalltext"><strong>Filesize </strong><em>{FILESIZE_FRIENDLY}</em> |
<strong>File Name </strong><em>{FILENAME}</em> | <strong># of Downloads </strong><em>{DOWNLOADS_FRIENDLY}</em>
<if {UPDATE_DATE} == {UPLOAD_DATE} then> </span><else>
<br />
<strong>File Updated </strong><em>{UPDATE_DATE}</em></span></if>
<hr>
|
I - don't know what to say...
I just copy pasted your code and it works perfectly. I must apologise for wasting your time
and thank you for the working block.
EDIT to add: Is there a way to access the index in the templates for example? I have a forum which shares a lot of pictures and so on and my content is mostly member generated. It would be very helpful to be able to access that index so that users can post individual images in their posts. I COULD just hard code the potential links but that sort of ruins the point of having a dynamic number of uploaded images.
(05-19-2014 10:12 AM)leefish Wrote: [ -> ]EDIT to add: Is there a way to access the index in the templates for example? I have a forum which shares a lot of pictures and so on and my content is mostly member generated. It would be very helpful to be able to access that index so that users can post individual images in their posts. I COULD just hard code the potential links but that sort of ruins the point of having a dynamic number of uploaded images.
I'm not quite sure what you're trying to do - is the display format not enough?
What template are you putting it in? In general, it doesn't make sense to have "an index" because there's a number of them.
I currently use the single file inputs for my images, this is the display format I use:
Code:
<if THIS_SCRIPT == 'newthread.php' OR THIS_SCRIPT == 'editpost.php' then>
<tr>
<tr><td class="tcat" align="center" colspan="2"><strong>Image 1 Preview & URL</strong></td></tr>
<tr>
<td class="trow1" align="center">
<img src="{$GLOBALS['threadfields']['pfpic']['url']}/thumb160x120" alt="" title="" />
</td>
<td class="trow1" valign="top">
<div class="float_left" style="width: 50%;">
<strong>BBCODE - 640 x 480 Thumbnail</strong><br />
<input name="prev_pfpic_bbcode" type="text" size="40" value="[IMG]{$mybb->settings['bburl']}/{$GLOBALS['threadfields']['pfpic']['url']}/thumb640x480[/IMG]" readonly="readonly" />
<input type="button" class="button" value="Select" onClick="javascript:this.form.prev_pfpic_bbcode.focus();this.form.prev_pfpic_bbcode.select();">
</div>
<div class="float_left" style="width: 50%;">
<strong>Direct Link</strong><br />
<input name="prev_pfpic_dl" type="text" size="40" value="<func htmlspecialchars_uni><a href="{$mybb->settings['bburl']}/{$GLOBALS['threadfields']['pfpic']['url']}">{$GLOBALS['threadfields']['pfpic']['filename']}</a></func>" readonly="readonly" />
<input type="button" class="button" value="Select" onClick="javascript:this.form.prev_pfpic_dl.focus();this.form.prev_pfpic_dl.select();">
</div>
<div class="float_left" style="width: 50%;">
<strong>BB Code - Inline Lightbox</strong><br />
<input name="prev_pfpic_html" type="text" size="40" value="[LIGHTBOX={$mybb->settings['bburl']}/{$GLOBALS['threadfields']['pfpic']['url']}]{$mybb->settings['bburl']}/{$GLOBALS['threadfields']['pfpic']['url']}/thumb640x480[/lightbox]" readonly="readonly" />
<input type="button" class="button" value="Select" onClick="javascript:this.form.prev_pfpic_html.focus();this.form.prev_pfpic_html.select();">
</div>
<div class="float_left" style="width: 50%;">
<strong>Full Size Image URL</strong><br />
<input name="prev_pfpic_full" type="text" size="40" value="{$mybb->settings['bburl']}/{$GLOBALS['threadfields']['pfpic']['url']}" readonly="readonly" />
<input type="button" class="button" value="Select" onClick="javascript:this.form.prev_pfpic_full.focus();this.form.prev_pfpic_full.select();">
</div>
</td>
</tr>
<else>
<a href="{URL}" rel="lightbox[find]"><img itemprop="image" src="{URL}/thumb160x120" alt="{$thread['subject']} Screenshot" width="{$GLOBALS['threadfields']['pfpic']['thumbs']['160x120']['w']}" id="pfpic" height="{$GLOBALS['threadfields']['pfpic']['thumbs']['160x120']['h']}" class="bigav ximage" /></a>
</if>
|
I repeat this for each image threadfield, so when the users are uploading they can press "submit images" (preview post in disguise) and they get a screen that looks like the attached. Then they can select an image and copy paste into the post.
The users are not very tech-savvy, so I try and make it easy for them to compose the post.
I am trying to make a tutorials set up, and sims tutorials can be picture heavy so it makes sense to use the multiple file upload for the images too.
You should still be able to use your display format above, just replace {$GLOBALS['threadfields']['pfpic']['url']} with {URL} etc.
Also worked perfectly - thank you very much