RE: Download pub type tute

"Michael Cortez" <[email protected]> Mon, 4 Aug 2003 08:24:22 -0700
Newsgroups gmane.comp.cms.xaraya.documentation
Message-ID <002901c35a9c$7ba7d320$0601a8c0@paxtera>
>> I never did find out how Download pub type is 
>> *supposed* to be setup. If anyone reads the tute, and has a 
>> better way of using dynamic data/uploads - let me know and 
>> I'll update the tute during my edit of it.

Heh, most interesting...

You've mixed two different ways of using the uploads module.

For the type of module that your doing I would suggest not using the
publication Body File Upload field.

I recommend the following:

Remove this:

>> Field: bodyfile (set field name, cannot be changed)
>> Label: Body File (this field is usually used for an 
>> uploaded text or HTML file)
>> Format: File Upload (this type of upload is for uploading 
>> text or HTML direct to the body text field)
>> Input: Make sure this checkbox is ticked so the field is 
>> available. 
>> This field seems to be optional for downloads, 
>> but I have had problems with uploads not working if this field 
>> is not left in the publication type definition 
>> (we are in beta tho atm  )

The reason why you had problems is that the upload form needs to be set to
::enctype="multipart/form-data"::

Currently the only way to do this via the admin interface is to setup the
Body File field in the publication type.

The way recommend doing it is to cusomtize the template used by the articles
module for displaying the submission and edit forms.

Copy the following file from the articles/xarTemplates to your theme
"admin-new.xd" as "admin-new-downloads.xt"  and then copy "admin-modify.xd"
as "admin-modify-news.xt"

Towards the top of the file, find the following lines:

:: <xar:if condition="!empty($withupload)">
::    <form method="post" action="&xar-modurl-articles-admin-create;"
#$formhooks['formaction']#>
:: <xar:else />
::    <form method="post" action="&xar-modurl-articles-admin-create;"
enctype="multipart/form-data" #$formhooks['formaction']#>
:: </xar:if>

Remove the <xar:if> so that it always results in the 2nd [else] branch:

<form method="post" action="&xar-modurl-articles-admin-create;"
enctype="multipart/form-data" #$formhooks['formaction']#>

You also no longer need the articles module to be hooked to the uploads
module.  You do still however need the DD module to be hooked to Uploads.


---

Okay, now for the 2nd part.  I would not recommend using the #ulid:id#
notation if for downloads unless your sure you'll only have zip files.

One of the things the #ulid:id# notation does is autodetect the file type,
and based on that file type, it displays the uploaded file in different
ways.  For a zip file it'll show a "zip" icon, along with an <a href=""> tag
for downloading that file.  However if someone uploads a GIF then, it'll
display that gif with an <img> tag.  

You can look in modules/uploads/xartemplates/ for the templates that make
this possible {and configurable} -- they're all named ::
user-viewdownload-*.xd

Instead, when you use DD like you have -- then there will be a DD field made
available for the display templates.  In your case $upload should be made
available.

You should then be able to place in your user-display-#pubtype#.xt file
something along the lines of:  <a href="$upload">Download Here</a>

All of this however requires the webmaster to actually edit their template
files, your solution however has the elagance of note requiring manual edit
of the templates.

If you have any further questions about the module, please don't hesitate to
ask.  "Real life" has taken me away from getting the module more feature
complete, but I'm hoping to get things sorted out enough that I can get back
to it soon {if not this week, maybe next}

--
Mike C.