{"action":"created","issue":{"url":"https://api.github.com/repos/engram-design/FeedMe/issues/64","repository_url":"https://api.github.com/repos/engram-design/FeedMe","labels_url":"https://api.github.com/repos/engram-design/FeedMe/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/engram-design/FeedMe/issues/64/comments","events_url":"https://api.github.com/repos/engram-design/FeedMe/issues/64/events","html_url":"https://github.com/engram-design/FeedMe/issues/64","id":159680769,"number":64,"title":"Matrix block order out of sync from JSON import","user":{"login":"thoughtfulweb","id":1379783,"avatar_url":"https://avatars.githubusercontent.com/u/1379783?v=3","gravatar_id":"","url":"https://api.github.com/users/thoughtfulweb","html_url":"https://github.com/thoughtfulweb","followers_url":"https://api.github.com/users/thoughtfulweb/followers","following_url":"https://api.github.com/users/thoughtfulweb/following{/other_user}","gists_url":"https://api.github.com/users/thoughtfulweb/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtfulweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtfulweb/subscriptions","organizations_url":"https://api.github.com/users/thoughtfulweb/orgs","repos_url":"https://api.github.com/users/thoughtfulweb/repos","events_url":"https://api.github.com/users/thoughtfulweb/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtfulweb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-10T17:12:26Z","updated_at":"2016-06-13T10:03:16Z","closed_at":null,"body":"I’m really struggling to get a Matrix block imported in the correct order so I have my fingers-and-toes crossed that you can help.\r\n\r\nI am creating a JSON file using P&T’s ElementAPI plugin.\r\n\r\nTo output the Matrix field data, you need to create and empty array and add data to this array as it loops through the blocks. If the data isn’t nested then the second value overwrites the first in the array. With this in mind, I get the following nested output:\r\n\r\n`{\r\n    \"data\": [\r\n        {\r\n            \"Body\": {\r\n                \"text\": [\r\n                    {\r\n                        \"Body\": \"<p>This entry contains content for all blocks to test the import</p>\"\r\n                    },\r\n                    {\r\n                        \"Body\": \"<p>Another text block</p>\"\r\n                    }\r\n                ],\r\n                \"video\": [\r\n                    {\r\n                        \"YouTube URL\": \"https://www.youtube.com/watch?v=LtMunDW_cBc\"\r\n                    },\r\n                    {\r\n                        \"YouTube URL\": \"https://youtu.be/X7FxX1l2u0I\"\r\n                    }\r\n                ]\r\n            }\r\n        }\r\n    ]\r\n}`\r\n\r\nFeedme does a great job importing all this data, with the first values for each block imported in the correct order, however, the second value gets appended to the end in an unordered sequence. \r\n\r\nMaintaining the order on import is essential for the project I am working on, so I wondered if there is a way to do this. \r\n\r\nIt would be easy to add each block’s sort order as an additional value, but I guess this would need to be processed by Feedme in some way.\r\n\r\nDo you have any ideas?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/engram-design/FeedMe/issues/comments/225539526","html_url":"https://github.com/engram-design/FeedMe/issues/64#issuecomment-225539526","issue_url":"https://api.github.com/repos/engram-design/FeedMe/issues/64","id":225539526,"user":{"login":"thoughtfulweb","id":1379783,"avatar_url":"https://avatars.githubusercontent.com/u/1379783?v=3","gravatar_id":"","url":"https://api.github.com/users/thoughtfulweb","html_url":"https://github.com/thoughtfulweb","followers_url":"https://api.github.com/users/thoughtfulweb/followers","following_url":"https://api.github.com/users/thoughtfulweb/following{/other_user}","gists_url":"https://api.github.com/users/thoughtfulweb/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtfulweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtfulweb/subscriptions","organizations_url":"https://api.github.com/users/thoughtfulweb/orgs","repos_url":"https://api.github.com/users/thoughtfulweb/repos","events_url":"https://api.github.com/users/thoughtfulweb/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtfulweb/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T10:03:16Z","updated_at":"2016-06-13T10:03:16Z","body":"I have noticed that there is some commented out code within FeedMe_FieldsService.php towards the bottom (line 472-491) that seems to refer to my idea of passing the block sort order attribute within the block data. \r\n\r\nI have (temporarily) uncommented this code, however, it seems to have no effect. \r\n\r\nI am sure it is commented out for a reason, but from what I understand this method would certainly help with my issue.\r\n\r\nHere’s a reduced example of the code generated with the additional order attribute:\r\n\r\n`{  \r\n   \"data\":[  \r\n      {  \r\n         \"Body\":{  \r\n            \"text\":[  \r\n               {  \r\n                  \"Body\":\"<p>This entry contains content for all blocks to test the import<\\/p>\",\r\n                  \"order\":\"1\"\r\n               },\r\n               {  \r\n                  \"Body\":\"<p>Another text block<\\/p>\",\r\n                  \"order\":\"9\"\r\n               }\r\n            ],\r\n            \"video\":[  \r\n               {  \r\n                  \"YouTube URL\":\"https:\\/\\/www.youtube.com\\/watch?v=LtMunDW_cBc\",\r\n                  \"order\":\"3\"\r\n               },\r\n               {  \r\n                  \"YouTube URL\":\"https:\\/\\/youtu.be\\/X7FxX1l2u0I\",\r\n                  \"order\":\"8\"\r\n               }\r\n            ]\r\n         }\r\n      }\r\n   ]\r\n}`\r\n\r\nAny help/guidance would very much appreciated. \r\n\r\nI would even be willing to pay for your time to look into this as it is key to my project.\r\n\r\nThanks,\r\n\r\nSimon\r\n"}}
{"actor":{"display_login":"thoughtfulweb"}}