1

Let's suppose I have a simple content type with title, body and file fields, and file field is multi value. I create a piece of content and upload some file in my field. Finally my content is something like

title : my title
body : somebody text come in body

file :

  1. file1

  2. file2

  3. file3

My question

I can change the order of files in node edit by drag them up or down, I want to know how I can load a file programmatically by its weight. I mean I want to upload a file that is shown first or second in node edit mode. How can I upload file form node programmatically, ordering by weight?

enter image description here

  • It's not clear what you are asking. When you say "load a file programmatically" do you mean UPload a file - ie. changing the node content - or load it in the sense of retrieving it? – Alfred Armstrong Apr 16 '15 at 13:25
  • @AlfredArmstrong if we have several field I want load one of them by weight – Yusef Apr 16 '15 at 13:40
4

When you change the order, the changes are saved as the delta in the database. For example if your field was called file you would access $node->field_file[$node->language][delta]. In your example above, the second file would be $node->field_file[$node->language][1] as the first file would be 0

  • lastDay I found my solution by looking at database field table. tnx for you attnetion and answer. – Yusef Apr 17 '15 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.