Someone mailed me asking me to repost this one from my old Point2Share Blog, so here it is!
I lost a couple of hours of my life today working on a really simple problem and so I thought I would just put a little tip out there in case anyone else bangs their head against it.
All I wanted to do was put some web parts, on a web part page, in a particular order, via an ONET.XML file. Simple right? All you need to do is give them sequential WebPartOrder values and away you go!
I did this, tested, and found that while the web part went in the correct zone (one on the right) they were going in with the wrong order. No matter what I tried (and I tried everything, was it alphabetical, the order in the ONET.XML, reverse WebPartOrder, argh!) I just couldn't get them to display the way I wanted.
Now this sort of thing is really ONET.XML 101, so it frustrated me even more. Taking a break from the problem last night I returned today to find it was actually pretty obvious. You have to make sure you get your Web Part Zone ID correct.
A tip, to be 100% sure of the ZoneID, export a web part from the page which is in the Zone you are interested in then examine the .dwp (or .webpart) file, or, better still, take a look at the Layout page looking for the specific WebPartZone tag, and then grab the ID attribute.
I think the reason it took me so long is that the web parts were going in the correct zone, what would have been better is if they gave some sort of error, like "Web Part Zone not found", or simply didn't appear on the page. I'm not sure how SharePoint selects the zone to place web parts when it is faced with an invalid Zone ID, but it seems I was partially a victim of coincidence.