Please help, I need assistance with the sequence of templates for File Upload
Posted: 13 August 2007 12:43 AM   [ Ignore ]
Jr. Member
RankRank
Total Posts:  45
Joined  2006-07-16

Hey folks, I think I’m very close to getting this to work, but I am baffled by the order of the templates as explained in the documentation, and how you are supposed to call the pop up, etc.

I think the docs might also need an example of the flow of templates (with a diagram) in addition to the usage of the tags and their parameters.

Here’s what I am doing:

I’m creating an ‘add image’ form for a weblog-based image gallery. What I thought the sequence was, looked like this:

1) An “upload file” template, a single-field form that asks you to browse for a file.
2) A “stand alone entry form (SAEF) template” that you get returned to after a successful upload.

What I thought would happen would be that template 1 (using the file_upload tag and its field_name parameter) would transer the uploaded file’s vital details to a field in the SAEF in template 2.
However this doesn’t work… while template #1 works great (it successfully uploads to the required directory), it doesn’t transfer anything to the form on template #2.

So what I understand now is that you are supposed to create some kind of popup? But which comes first, your SAEF or your file upload? Where does the file_confirm come in?

Is the template sequence supposed to be as so?

Template 1) SAEF form with an “upload file” button
Template 2) “Upload file” button opens a pop-up window which contains template #2, the file_upload template.
Template 3) After successful upload, user “confirms” the upload with another template that opens in the pop-up window after the successful upload (why is this necessary?) and closing the window with the button places the file reference back in a field in template 1).

Or is the SAEF supposed to be in the popup window? Help, confused…

If it’s like this, how do I get the original popup to work?

Here’s what my Template #1 looks like:

<h5><b>Step 1 of 2</b></h5>
{exp:file_upload:upload_form form_name="entryform" destination="Fan Gallery folder" field_name="image_file" return="fans/add_image_details"}

<p>Browse for the image on your computer that you would like to upload.</p>
<
p><input class="filebrowser" type='file' name='userfile' />&nbsp;</p>
<
p class="formcaption">Your image has to be no more than 750 pixels wide, and no more than 600 pixels tall.</p>

<
input type='submit' value='Upload' />
{/exp:file_upload:upload_form}

and Template #2:

<h5>Step 2 of 2: Add details for the image</h5>

{exp:weblog:entry_form weblog="{my_weblog}" return="fans/add_image_details" return="fans/add_image_details" status="Draft"}
<p>* Title<br />
<
input type="text" class="input" name="title" id="title" value="" size="50" maxlength="100" onkeyup="liveUrlTitle();" /></p>
<
p class="formcaption">Give your image a title.</p>

<
p>* Gallery section<br />
{category_menu}
<select name="category[]" class="select">
{select_options}
</select>
{/category_menu}
</p>
<
p class="formcaption">Which gallery are you posting this image in?</p>

<
p>* Large Image filename:<br />
<
input type="text" dir="ltr" name="field_id_72" class="input" value="" maxlength="256" size="50" onclick="setFieldName(this.name)" /></p>
<
p class="formcaption">The file you just uploaded.</p>

<
p>Image Caption:<br />
<
textarea name="field_id_73" class="textarea" dir="ltr" cols="50" rows="6" onclick="setFieldName(this.name)"></textarea></p>
<
p class="formcaption">Give the image some backstory or some details.</p>

<!--
other custom fields -->

<
input type="submit" name="submit" value="Preview this info">
{/exp:weblog:entry_form}


As you can see, what I’m expecting is that the first template drop the info into field_id_72 on template #2, the input field for the image_file custom field in the weblog. But that’s not what’s happening.

Thanks so much for your help!! Like I said, I have it very close I think.

Profile
 
 
Posted: 13 August 2007 09:48 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  701
Joined  2004-03-30

OS,

You’re description here is correct.

Template 1) SAEF form with an “upload file” button
Template 2
) “Upload file” button opens a pop-up window which contains template #2, the file_upload template.
Template 3) After successful upload, user “confirms” the upload with another template that opens in the pop-up window after the successful upload (why is this necessary?) and closing the window with the button places the file reference back in a field in template 1).

This file upload module works just like the EE file upload functionality in the CP, except that you can apply your own styles to the popup that is shown and you can also hide the extra file upload locations that you don’t want users to see.

mk

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 13 August 2007 12:31 PM   [ Ignore ]   [ # 2 ]
Jr. Member
RankRank
Total Posts:  45
Joined  2006-07-16

Ahhhh, OK, let me try that. Sounds like that will work decently.

I have a further question, while I’m setting this up, that I know I’ll run into immediately if it works like EE’s upload and placement. Rather than placing something like

<img src="{filedir_9}0e0b1.jpg" width="450" height="600" />

in the field, do you know of a way to get it to strip the image tag, and just leave the file reference:

0e0b1.jpg

I wish this was an option in EE, the reason being that the template in which the image will be displayed is perfectly capable of putting tags, attributes and CSS around it. For instance, I run my images through phpThumb to produce thumbnails of the uploaded images. If you can direct me to lines I can comment out, alter or add in the module for this, that would be great… although I am aware I might have to do that in EE instead.

Thanks, I’ll post my finished working template as a template here for others when I’m done.

Profile
 
 
Posted: 13 August 2007 12:51 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  701
Joined  2004-03-30

OS,

We need to do what you describe quite often. We handle it easily by using the extract_url plugin on the front-end template rather than parse the url out at submission time.

mk

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 22 August 2007 02:26 PM   [ Ignore ]   [ # 4 ]
Jr. Member
RankRank
Total Posts:  45
Joined  2006-07-16

Awesome.  Thank you.

OK, I finally have time to get back into file uploading today. Using this thread, I was able to figure out how to make the button that launches the file_upload_template in the popup window.

However, I’m confused because I’m getting this error in the popup window instead of the uploading form.

"No field was provided to receive the link created by file upload. Please contact customer service."

In my code on file_upload_template (which appears in a popup window), the code is as in the documentation (with my own downloads directory title, and field_name in the weblog and on the originating SAEF where it’s supposed to place the file reference).

{exp:file_upload:upload_form form_name="entryform" destination="Main Downloads Directory” field_name="document_url" return="docs/file_upload_placement" rename_duplicates="yes"}
<input type=’file’ name=’userfile’ />
<input type=’submit’ value=’Upload’ />
{/exp:file_upload:upload_form}

In my weblog, and in the original SAEF that calls the popup template with file_upload, I definitely have a field called document_url, and the SAEF form is definitely called entryform. I tried changing the field to field_id_33 (which is document_url’s actual field #), and even to ‘userfile’, but no avail. I can’t see to get around this error, and it just seems like I’m missing something simple. 

Sorry if I’m just being really dense guys. It’s kind of like working blind without a workflow of how it’s all supposed to go, or screenshots or anything. Thanks for your help, especially if it can come quickly! smile

R o B

Profile
 
 
Posted: 27 August 2007 09:04 AM   [ Ignore ]   [ # 5 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

Are you still working on that?

 Signature 

Ingmar Greil

Profile
 
 
Posted: 27 August 2007 09:10 AM   [ Ignore ]   [ # 6 ]
Jr. Member
RankRank
Total Posts:  45
Joined  2006-07-16

Nope. This thread and another helped me solve it! Thanks again!

I have further questions, too, but I’ve been insanely busy with another site just prior to launch. I’ll be able to get back into it, once again, in a few days.

Profile
 
 
Posted: 27 August 2007 09:37 AM   [ Ignore ]   [ # 7 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

Hey, tell me about busy… Just wanted to make sure no one gets overlooked smile

 Signature 

Ingmar Greil

Profile