Re: [dotcms] Updating fileupload file in content structure

52 views
Skip to first unread message

Maria Ahues Bouza

unread,
Jun 15, 2012, 12:21:49 PM6/15/12
to dot...@googlegroups.com
Hello,

Is this code not working?

The logic looks ok but I don't know what you're doing with these variables on the code so I don't know if it's okay or not.

The only thing that's confusing is that you're setting two different objects on $defaultUploadedFile, one is the uploadedFile that comes in the content object,and the second case the uploaded file from the browser.

Since I don't see the entire code I'm not sure how you're handling that later in the code.

Thanks
Maria

On Fri, Jun 15, 2012 at 3:38 AM, blumenr <villeskantsb...@googlemail.com> wrote:
I have created a content structure with one file type field. On the website (frontend) I prepared a form which allows the user to edit  the data of this content structure. If a user had uploaded an image previously and does not choose an image (in a later edit), the image shall not be removed from the content (structure). In case the user chooses an image, the image shall be replaced, of course. How would my velocity code look like in order to make this work? Currently, I have the following approach:


#if($UtilMethods.isSet($oldAnswer))
             
      #set($submitContentSrc = "/vtl/content_form_macro_override_edit.vtl")
             
      #set($defaultAnswernumeric = $oldAnswer.answernumeric)
      #set($defaultAnswertext = $oldAnswer.answertext)
     
      #if($request.getParameter('uploadedFile') == "")
       
              #set($defaultUploadedFile = $oldAnswer.uploadedFile)
      #else
              #set($defaultUploadedFile = $request.getParameter('uploadedFile'))
     
      #end
             
      #set($structureType = "Aduseranswers")
      #set($theinode = $oldAnswer.inode)
      #set($theidentifier = $oldAnswer.identifier)
      #set($uid = $session.getAttribute("USER_ID"))

Thanks in advance!

--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/dotcms/-/ApxNAgbzv9UJ.
To post to this group, send email to dot...@googlegroups.com.
To unsubscribe from this group, send email to dotcms+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dotcms?hl=en.



--
Community Manager

dotCMS
Main: 305.900.2001
Fax: 305.397.2579
www.dotcms.com
http://www.twitter.com/dotCMS
http://www.facebook.com/dotCMS
http://www.twitter.com/mabouza

Please consider the planet before printing this email.

Ville Skants

unread,
Jun 15, 2012, 12:47:43 PM6/15/12
to dot...@googlegroups.com
It seems that there is no built-in way to edit content structure data on the front-end? Here's also the later part of my code:


#if($UtilMethods.isSet($oldAnswer))
              
      #set($submitContentSrc = "/vtl/content_form_macro_override_edit.vtl")
     
      #set($defaultAnswernumeric = $oldAnswer.answernumeric)
      #set($defaultAnswertext = $oldAnswer.answertext)
       
      #if($request.getParameter('uploadedFile') == "")
       
              #set($defaultUploadedFile = $oldAnswer.uploadedFile)
      #else
              #set($defaultUploadedFile = $request.getParameter('uploadedFile'))
     
      #end
              
      #set($structureType = "Aduseranswers")
      #set($theinode = $oldAnswer.inode)
      #set($theidentifier = $oldAnswer.identifier)
      #set($uid = $session.getAttribute("USER_ID"))
      
      #else
            #set($submitContentSrc = "/vtl/content_form_macro_override.vtl")
      #end
            #if($content.answertype.selectValue == "i" || $content.answertype.selectValue == "f")
              #set($dontShowFields = "answertext, uploadedFile")
            #elseif($content.answertype.selectValue == "t")
              #set($dontShowFields = "answernumeric, uploadedFile")
            #elseif($content.answertype.selectValue == "u")
              #set($dontShowFields = "answernumeric")
            #end
            #set($contentAutoPublish = true)
            #set($currentURLMapContent = $dotcontent.find($URLMapContent.identifier))
            #set($pageUri = $currentURLMapContent.getUrlMap())
              #set($pp = $pp - 1)
            #set($myUrl = $pageUri + "?page=" + $pp)
            #set($contentFormReferer = $!myUrl)
      #set($Parent_Aduserresearches-Child_Aduseranswers = $myAduserresearches.identifier)
      #set($Parent_Adquestions-Child_Aduseranswers  = $content.identifier)
            #submitContent('aduseranswers')



2012/6/15 Maria Ahues Bouza <ma...@dotcms.com>

Maria Ahues Bouza

unread,
Jun 15, 2012, 12:55:17 PM6/15/12
to dot...@googlegroups.com
No, right now there isn't a macro to edit content in the frontend.

I don't think you can use submitContent to save this content though.

Are you getting errors with this code? What is working and what is not working?

Can you edit content without the file upload? Is that the only thing that is not working on the code right now?

Ville Skants

unread,
Jun 15, 2012, 1:07:37 PM6/15/12
to dot...@googlegroups.com
Yes. The file upload is the only thing which isn't working. This is an application tool which allows users to write and upload answers and save(submit) them. Users can log out and again log in and the old answers are retrieved from the structures. After this a user can save again his/her answer. The problem is that when a user uploads a new file, it doesn't override the old one. So a user can edit and update his textarea text but overriding the old file isn't working..

Maria Ahues Bouza

unread,
Jun 15, 2012, 2:26:06 PM6/15/12
to dot...@googlegroups.com
Let me see if we have an example anywhere on how to do this.

If not, I'll try it on demo on Monday.
Reply all
Reply to author
Forward
0 new messages