Alsteld
October 30, 2020, 12:51pm
1
Hello Guys!
I need to make several fields with attachments with different content on one page. I made three fields with attachments, but only the first field works correctly (I can load and delete). But the rest do not work (displaying attachments and deleting and that’s it).
I need all fields to work correctly
Can anyone help please?
Sorry for my bad English
Hi, I’d need more context to understand what you mean.
For a start, WDYM by “making fields with attachments”? Are you referring to creating 3 xproperties in an XClass? If so, of what type?
but only the first field works correctly (I can load and delete)
I have no idea what you mean to “load” or “delete” a field. What is a field? And what does “work” mean?
Thanks
I need to do something like this
When I click the first Browse button I can download my selected file and it downloads in attachments. But when I press the second Browse button, I can only select the file and that’s it. The file is not loading. Corresponding to the third Browse button
I have created three classes for storing attachments. Each class is responsible for each group of attachments. And in each class I implemented a velocity macro:
{{velocity}}
{{html}}
$xwiki.jsfx.use('uicomponents/widgets/upload.js', {'forceSkinAction': true, 'language': ${xcontext.locale}})
$xwiki.ssfx.use('uicomponents/widgets/upload.css', true)
$xwiki.jsfx.use('js/xwiki/viewers/attachments.js', {'forceSkinAction': true, 'language': ${xcontext.locale}})
$xwiki.ssfx.use('js/xwiki/viewers/attachments.css', true)
#set($solutionFiles = $xwiki.getDocument("$doc.getPlainTitle()_SolutionFiles"))
<div id="attachmentscontent" class="xwikiintracontent">
<div id="attw">
<div id="_attachments" class="attachments">
#if ("$!{request.forceTestRights}" == "1")#template("xwikivars.vm")#end
#template('attachment_macros.vm')
#set ($attachmentsSolution = $solutionFiles.attachmentList)
#sortAttachments($attachmentsSolution $request.sortAttachmentsBy)
#if ($attachmentsSolution.size() > 0)
#displayAttachments($attachmentsSolution)
#else
<p class="noitems">$services.localization.render('core.viewers.attachments.noAttachments')</p>
#end
</div> ## attachments
#deleteAttachmentModal
#if($hasEdit || $hasAdmin)
<form action="$solutionFiles.getURL("upload")" enctype="multipart/form-data" method="post" id="AddAttachment">
<div>
<input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
<input type="hidden" name="xredirect" value="$escapetool.xml($redirect)" />
<fieldset id="attachform">
<legend>$services.localization.render('core.viewers.attachments.upload.title')</legend>
<div class="fileupload-field"><label class="hidden" for="xwikiuploadfile">$services.localization.render('core.viewers.attachments.upload.file')</label><input id="xwikiuploadfile" type="file" name="filepath" size="40" class="uploadFileInput noitems" data-max-file-size="$!escapetool.xml($xwiki.getSpacePreference('upload_maxsize'))" /></div>
</fieldset>
</div>
</form>
#end
</div>
</div>
{{/html}}
{{/velocity}}
Ok so you’re not using XWiki out of the box. I guess it means you have a bug in your code then
EDIT: I don’t have the time to look into your code ATM but maybe someone from the community could try to help you out.
vmassol,
thank you very much for your answer