Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Styling Multiple File Inputs
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Styling Multiple File Inputs
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:
1
2
3
4
5
6
7
8
9
<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&nbsp;</strong><em>{$GLOBALS['threadfields_x']['mupload']['items'][index]['filesize_friendly']}</em> |
<strong>File Name&nbsp;</strong><em>{$GLOBALS['threadfields_x']['mupload']['items'][index]['filename']}</em> | <strong># of Downloads&nbsp;</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>&nbsp;</span><else>
<br />
<strong>File Updated&nbsp;</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?



[Image: leelink.gif]
MYBB1.6 & XThreads
05-17-2014 11:35 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Styling Multiple File Inputs
For display formats, you don't need to use $threadfields_x etc, {FILESIZE_FRIENDLY} {UPLOAD_DATE} etc should work, for example.

My Blog
05-18-2014 08:20 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Styling Multiple File Inputs
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.


Attached File(s) Thumbnail(s)
   


[Image: leelink.gif]
MYBB1.6 & XThreads
05-19-2014 12:46 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Styling Multiple File Inputs
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
1
2
3
4
5
6
7
8
9
<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&nbsp;</strong><em>{FILESIZE_FRIENDLY}</em> |
<strong>File Name&nbsp;</strong><em>{FILENAME}</em> | <strong># of Downloads&nbsp;</strong><em>{DOWNLOADS_FRIENDLY}</em>
<if {UPDATE_DATE} == {UPLOAD_DATE} then>&nbsp;</span><else>
<br />
<strong>File Updated&nbsp;</strong><em>{UPDATE_DATE}</em></span></if>
<hr>


My Blog
05-19-2014 09:35 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Styling Multiple File Inputs
I - don't know what to say...

I just copy pasted your code and it works perfectly. I must apologise for wasting your time Frown 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.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 05-19-2014 11:23 AM by leefish.)
05-19-2014 10:12 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: Styling Multiple File Inputs
(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.

My Blog
05-19-2014 04:48 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Styling Multiple File Inputs
I currently use the single file inputs for my images, this is the display format I use:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<if THIS_SCRIPT == 'newthread.php' OR THIS_SCRIPT == 'editpost.php' then>
	<tr>
	<tr><td class="tcat" align="center" colspan="2"><strong>Image 1 Preview &amp; 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.



Attached File(s) Thumbnail(s)
   


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 05-19-2014 07:33 PM by leefish.)
05-19-2014 07:32 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #8
RE: Styling Multiple File Inputs
You should still be able to use your display format above, just replace {$GLOBALS['threadfields']['pfpic']['url']} with {URL} etc.

My Blog
05-20-2014 09:27 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #9
RE: Styling Multiple File Inputs
Also worked perfectly - thank you very much Biggrin


[Image: leelink.gif]
MYBB1.6 & XThreads
05-22-2014 10:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: